From 71f9b0ff84f80ef284f10795d6bdf06e95818c62 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Fri, 22 Jun 2012 20:55:18 +0000 Subject: [PATCH] Convert privmsg to say --- email.awk | 2 +- irc.awk | 24 +++++++++++++++++------- spades.awk | 16 ++++++++-------- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/email.awk b/email.awk index 090a913..cf9c102 100644 --- a/email.awk +++ b/email.awk @@ -54,7 +54,7 @@ function mail_prep(user, chan, } } } - privmsg(chan, "notifying " user " at " addr) + say(chan, "notifying " user " at " addr) mail_send(addr, "Message for " user " in " chan, body) delete mail_ready[user][chan] } diff --git a/irc.awk b/irc.awk index 808eb36..880f76b 100644 --- a/irc.awk +++ b/irc.awk @@ -58,16 +58,26 @@ function connect(server, nick, channel) { send("NICK " nick) } } -function privmsg(to, msg) { + +function say(to, msg) { + if (msg == "") { + msg = to + if (DST ~ "^#") + to = DST + else if (DST == NICK && FROM) + to = FROM + else + to = CHANNEL + } send("PRIVMSG " to " :" msg) } -function say(msg) { - if (DST ~ "^#") - privmsg(DST, msg) - else if (DST == NICK && FROM) - privmsg(FROM, msg) + +function action(to, msg) +{ + if (msg) + say(to, "\001ACTION " msg "\001") else - privmsg(CHANNEL, msg) + say("\001ACTION " to "\001") } function reply(msg) { diff --git a/spades.awk b/spades.awk index efd4769..d8bfef4 100644 --- a/spades.awk +++ b/spades.awk @@ -265,7 +265,7 @@ FROM == OWNER && delete sp_hands[$2] for (i=3; i<=NF; i++) sp_hands[$2][$i] = 1 - privmsg(sp_channel, FROM " is cheating for " $2) + say(sp_channel, FROM " is cheating for " $2) } @@ -279,7 +279,7 @@ FROM == OWNER && sp_state = "join" sp_channel = DST say(sp_owner " starts a game of Spades to " sp_playto "!") - #privmsg("#rhnoise", sp_owner " starts a game of Spades in " DST "!") + #say("#rhnoise", sp_owner " starts a game of Spades in " DST "!") } } @@ -341,7 +341,7 @@ sp_state == "bid" && say("Bidding goes to " sp_player "!") } else { for (p in sp_players) - privmsg(p, "You have: " sp_hand(p)) + say(p, "You have: " sp_hand(p)) sp_state = "play" for (i=0; i<2; i++) { if (sp_nil[i] == 2 || sp_nil[i+2] == 2) { @@ -377,7 +377,7 @@ sp_state == "pass" && } else { sp_pass[sp_players[FROM]] = $2 - privmsg(sp_channel, FROM " passes a card") + say(sp_channel, FROM " passes a card") } if (((sp_nil[0] != 2 && sp_nil[2] != 2) || (sp_pass[0] && sp_pass[2])) && ((sp_nil[1] != 2 && sp_nil[3] != 2) || (sp_pass[1] && sp_pass[3]))) { @@ -387,9 +387,9 @@ sp_state == "pass" && delete sp_hands[sp_order[i]][card] sp_hands[sp_order[partner]][card] = 1 } - privmsg(sp_channel, "Cards have been passed, play starts with " sp_player "!") + say(sp_channel, "Cards have been passed, play starts with " sp_player "!") for (p in sp_players) - privmsg(p, "You have: " sp_hand(p)) + say(p, "You have: " sp_hand(p)) sp_state = "play" } } @@ -400,7 +400,7 @@ sp_state ~ "(play|bid)" && say(".slap " FROM ", you are not playing.") } else { sp_looked[sp_players[FROM]] = 1 - privmsg(FROM, "You have: " sp_hand(FROM)) + say(FROM, "You have: " sp_hand(FROM)) } } @@ -425,7 +425,7 @@ sp_state == "play" && } else { sp_play(card) - privmsg(FROM, "You have: " sp_hand(FROM)) + say(FROM, "You have: " sp_hand(FROM)) if (sp_state == "play") { if (sp_piles) say(sp_player ": it is your turn! " \ -- 2.43.2