From: Andy Spencer Date: Sun, 22 Jan 2012 08:16:12 +0000 (+0000) Subject: better X-Git-Url: http://pileus.org/git/?p=~andy%2Frhawk;a=commitdiff_plain;h=46821ac88a45b7f96834f1b6f8822db9dd5bd27d better --- diff --git a/.gitignore b/.gitignore index b25c15b..b72f9be 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *~ +*.swp diff --git a/irc.awk b/irc.awk index 6fc0c46..0681885 100644 --- a/irc.awk +++ b/irc.awk @@ -19,15 +19,15 @@ # 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 a077499..62b5207 100755 --- 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" } diff --git a/spades.awk b/spades.awk index 844326a..3eeab90 100644 --- a/spades.awk +++ b/spades.awk @@ -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") diff --git a/testirc.txt b/testirc.txt index 88662c5..7508afa 100644 --- a/testirc.txt +++ b/testirc.txt @@ -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