]> Pileus Git - ~andy/rhawk/commitdiff
Convert privmsg to say
authorAndy Spencer <andy753421@gmail.com>
Fri, 22 Jun 2012 20:55:18 +0000 (20:55 +0000)
committerAndy Spencer <andy753421@gmail.com>
Fri, 22 Jun 2012 20:55:18 +0000 (20:55 +0000)
email.awk
irc.awk
spades.awk

index 090a91312c2c6b6190b033786f47ceb670fe3649..cf9c102d9430bb3da52b9108c2c6d8501062c0b8 100644 (file)
--- 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 808eb36a06e0902eee9df04497c4f4b8bc686ad8..880f76b2e0c0070718a677696e9d31874bc59375 100644 (file)
--- 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) {
index efd4769c375905fb880528fa57d6ed8df56a76f2..d8bfef4f943f9245f5ebed01bb548423aa32d6b9 100644 (file)
@@ -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! " \