]> Pileus Git - ~andy/rhawk/commitdiff
better
authorAndy Spencer <andy753421@gmail.com>
Sun, 22 Jan 2012 08:16:12 +0000 (08:16 +0000)
committerAndy Spencer <andy753421@gmail.com>
Sun, 22 Jan 2012 08:16:12 +0000 (08:16 +0000)
.gitignore
irc.awk
rhawk
spades.awk
testirc.txt

index b25c15b81fae06e1c55946ac6270bfdb293870e8..b72f9be2042aa06db9cb3a6f533f953b5ce29901 100644 (file)
@@ -1 +1,2 @@
 *~
+*.swp
diff --git a/irc.awk b/irc.awk
index 6fc0c468ead2df40d8d3c1dc32d771ab237edf16..0681885f41386b2e8f0684c57f91a19d8030419e 100644 (file)
--- a/irc.awk
+++ b/irc.awk
 
 # Debugging
 function send(msg) {
-       #print "  > " msg > "/dev/stderr"
+       print "  > " msg > "/dev/stderr"
        print msg
-       #system("sleep 1")
+       system("sleep 1")
        fflush()
 }
 
 // {
        #print ""         > "/dev/stderr"
-       #print "  < " $0  > "/dev/stderr"
+       print "  < " $0  > "/dev/stderr"
 }
 
 function debug(msg) {
@@ -74,12 +74,17 @@ function reply(msg) {
 
 function join(chan) {
        send("JOIN " chan)
+       send("TOPIC " chan)
 }
 
 function part(chan) {
        send("PART " chan)
 }
 
+function topic(chan, msg) {
+       send("TOPIC " chan " :" msg)
+}
+
 # Reloading
 BEGIN {
        if (CHILD == "") {
@@ -131,3 +136,8 @@ CMD == "001" && MSG ~ /Welcome/ {
 CMD == "PING" {
        send("PING " MSG)
 }
+
+CMD == "332" ||
+CMD == "TOPIC" {
+       topics[DST] = MSG
+}
diff --git a/rhawk b/rhawk
index a0774999f85cba2694a77adab4d67d24ac31cdab..62b5207de40a1506e6f3bcdda7eca19f7d38af7a 100755 (executable)
--- a/rhawk
+++ b/rhawk
@@ -66,6 +66,28 @@ CMD == "NICK" && FROM in bots {
        plain[FROM] = 0
 }
 
+# SFV Lug
+(systime()-lastpoll > 60*60*24 && CMD == "PING") ||
+(/^\.poll/ && DST == "#sfvlug" && CMD == "PRIVMSG") {
+       chan = "#sfvlug"
+       if (!topics[chan])
+               next
+       lastpoll = systime()
+       cmd = "curl -s http://sfvlug.org/"
+       day = "(Sun|Mon|Tue|Wed|Thu|Fri|Sat)"
+       web = "next meeting.*" day "\\w+[, ]+([A-Z]\\w+) +([0-9]+)[, ]+([0-9]+)"
+       irc = day "\\w*[, ]+([A-Z]\\w+) +([0-9]+)"
+       while (cmd | getline line) {
+               if (match(line, web, arr)) {
+                       new = arr[1] " " arr[2] " " arr[3]
+                       sub(irc, new, topics[chan])
+                       topic(topics[chan])
+                       next
+               }
+       }
+}
+
+
 # Fortune
 TO == NICK && /^/             { extra = ""   }
 TO == NICK && /^.fortune.*-o/ { extra = "-o" }
index 844326a076483817d87c6a72a7eac733b10dbfa7..3eeab902d350454fdd95d37a05ce53afa3b8fb22 100644 (file)
@@ -1,7 +1,3 @@
-# Todo:
-#   - highest bidder leads
-#   - show card after play
-
 # Functions
 function sp_init(cards, tmp0, tmp1)
 {
@@ -149,7 +145,7 @@ function sp_score(  bids, tricks)
                bids   = sp_bids[i]   + sp_bids[i+2]
                tricks = sp_tricks[i] + sp_tricks[i+2]
                bags   = tricks - bids
-               if (sp_bags(i) + bags > 10) {
+               if (sp_bags(i) + bags >= 10) {
                        say(sp_team(i) " bag out")
                        sp_scores[i] -= 100
                }
@@ -456,6 +452,7 @@ sp_state == "play" &&
            sp_order[3] " took " int(sp_tricks[3]) "/" int(sp_bids[3]))
 }
 
+(TO == NICK || DST == sp_channel) &&
 /^\.(score|status)$/ {
        if (sp_state == "new") {
                say("There is no game in progress")
index 88662c5a7a67bbabc60d7d70aa1966b46052e70d..7508afa05495cdfc15177edc8fb7f7898e8b7d18 100644 (file)
@@ -1,5 +1,2 @@
-:andy753421!~a@c.d PRIVMSG #rhnoise :spades
-:andy753421!~a@c.d PRIVMSG #rhnoise :unicode :)
-:andy753421!~a@c.d PRIVMSG #rhnoise :spades
-:andy753421!~a@c.d PRIVMSG #rhnoise :unicode :(
-:andy753421!~a@c.d PRIVMSG #rhnoise :spades
+:andy753421!~a@c.d TOPIC #sfvlug :San Fernando Valley Linux Users Group | Meeting: Sat January 21, 6:00pm Denny's Van Nuys | Website: www.sfvlug.org & Wiki: http://tinyurl.com/tabrr & Meetup: http://meetup.com/sfvlug | Knowledge is power. http://tinyurl.com/2xr7sd
+:andy753421!~a@c.d PRIVMSG #sfvlug :.poll