X-Git-Url: http://pileus.org/git/?p=~andy%2Frhawk;a=blobdiff_plain;f=rhawk;h=0bc31a3ceadaf1512ed2ac9837a26ef77773f8b9;hp=0ba96aac3fe855d2abec376c3b9a490e123caf50;hb=HEAD;hpb=53a82f76c46868765f63c252af63289b6debe20a diff --git a/rhawk b/rhawk index 0ba96aa..0bc31a3 100755 --- a/rhawk +++ b/rhawk @@ -3,13 +3,15 @@ @include "irc.awk" @include "json.awk" @include "spades.awk" -#@include "email.awk" +@include "email.awk" +@include "remind.awk" +@include "sfvlug.awk" # Initialization BEGIN { json_load("var/login.json", login); json_load("var/nounicode.json", nounicode); - json_load("var/nocolor.json", nocolors); + json_load("var/nocolor.json", nocolor); OWNER = login["owner"]; @@ -22,10 +24,12 @@ BEGIN { delete login if (FIRST) { - join("#rhnoise") + join("#rhtest") join("#rhspades") join("#sfvlug") } + + PROCINFO["sorted_in"] = "@ind_str_asc"; } # Admin @@ -97,53 +101,6 @@ CMD == "NICK" && FROM in bots { json_save("var/nocolor.json", nocolor); } -# SFV Lug -function email(to, from, subj, body, sendmail) -{ - from = NICK "" - subj = "Update sfvlug.org!" - body = "The next SFVLUG meeting is TBA!" - sendmail = "/usr/sbin/sendmail '" to "'" - print "To: " to | sendmail - print "From: " from | sendmail - print "Subject: " subj | sendmail - print "" | sendmail - print body | sendmail - say("Topic out of date, emailing " to); - close(sendmail) -} - -BEGIN { pollchan = "#sfvlug" } -(CMD == "PING" && systime()-lastpoll > 60*60*24) || -(CMD == "PRIVMSG" && /^\.poll/) { - if (!TOPICS[pollchan]) { - debug("Unknown topic for " pollchan); - send("TOPIC " pollchan) - next - } - _curl = "curl -s http://sfvlug.org/" - _day = "(Sun|Mon|Tue|Wed|Thu|Fri|Sat)" - _web_tba = "next meeting is: TBA" - _web_ptrn = "next meeting.*" _day "\\w+[, ]+([A-Z]\\w+) +([0-9]+)[, ]+([0-9]+)" - _irc_ptrn = _day "\\w*[, ]+([A-Z]\\w+) +([0-9]+)" - while (_curl | getline _line) { - #if (match(_line, _web_tba)) - # email("Brian "); - if (match(_line, _web_ptrn, _parts)) { - _date = _parts[1] " " _parts[2] " " _parts[3] - _topic = TOPICS[pollchan] - sub(_irc_ptrn, _date, _topic) - if (_topic != TOPICS[pollchan]) - topic(pollchan, TOPICS[pollchan] = _topic) - else - debug("topic is already correct") - break - } - } - lastpoll = systime() - close(_curl) -} - # Versin/Uptime function head(cmd, var) { cmd | getline var @@ -160,13 +117,15 @@ function uptime(time, fmt) { time / (1 ) % 60) } BEGIN { - up_version = head("git describe --always --dirty") + up_version = head("git describe --always") + up_dirty = head("git describe --always --dirty") up_author = head("git log -n1 --format=format:%an") up_message = head("git log -n1 --format=format:%s") up_reload = systime(); } /^\.(version|rev)/ { - say("version: " up_version " - " up_author " - " up_message) + say("version: " up_dirty " - " up_author " - " up_message) + say("http://pileus.org/git/?p=~andy/rhawk;h=" up_version) } /^\.uptime/ { _now = systime(); @@ -187,6 +146,31 @@ BEGIN { say("no auth info for " _who) } +# GeoIP Lookup +function geoip(ip, dat, cmd, line, parts) { + dat = "/usr/share/GeoIP/GeoIPCity.dat" + + cmd = "geoiplookup -f " dat " " ip + cmd | getline line + close(cmd) + + if (split(line, parts, /[:,] /) >= 9) + return parts[8] "," parts[9] " -- " \ + parts[6] ", " parts[4] ", " parts[3] + else + return "not found" +} + +/^\.geoip (([0-9a-zA-Z_.-]+) *)*$/ { + for (_i=2; _i<=NF; _i++) { + if ($_i in USERS) + say(geoip(USERS[$_i]["host"]) " -- " \ + $_i " -> " USERS[$_i]["host"]) + else + say(geoip($_i) " -- " $_i) + } +} + # Fortune TO == NICK && /^/ { extra = "" } TO == NICK && /^\.?fortune.*-o/ { extra = "-o" } @@ -202,6 +186,16 @@ TO == NICK && /^\.?fortune/ { next } +/\<[Bb][Oo][Ff][Hh]\>/ { + _cmd = "fortune bofh-excuses" + _cmd | getline _fortune + _cmd | getline _fortune + _cmd | getline _fortune + close(_cmd) + say(_fortune) + next +} + # Morse code BEGIN { morse["/" ] = " " @@ -308,6 +302,11 @@ TO == NICK && DST ~ /^#/ { #say("Hello, " FROM) } +/^\.nestroyeti/ { + say(sprintf("Temperature: %4.1f F Humidity: %2d%%", + rand()*20+65, rand()*20+40)) +} + #DST != "#sfvlug" && !(FROM in bots) && CMD == "PRIVMSG" && @@ -316,12 +315,6 @@ MSG !~ /^\./ && say("Awk, awk, awk! I'm a bird!") } -!(FROM in bots) && -((TO == NICK && /(help|halp)/) || - /^[^.](help|halp)/) { - reply("Nothing can help you now..") -} - /(\<[Hh][Oo]\>.*){3}/ { say("\00309Merry \00304Christmas!") } @@ -358,6 +351,14 @@ FROM == "rhnoise" && $2 == "slaps" && $3 == NICK { say("Springtime for Hitler and Germany!"); } +/^.drank mauchter/ { + if (!drank) { + system("sleep " 2) + say("\x02MD 20/20\x0f - \x02Morgen David\x0f - \x02Under an overpass\x0f - ***** (3 minutes ago)"); + } + drank=1 +} + # God damn commands FROM == "rhnoise" && load_mod { say(".load " load_mod) @@ -390,6 +391,7 @@ FROM == "rhnoise" && load_mod { # Decrementer BEGIN { user_scores[0] = 1; + delete user_scores } /^\.(scores|scoreboard)$/ { @@ -424,6 +426,30 @@ tolower($0) ~ /\/ { } } +# Vote relay +DST != "#rhnoise" && DST != NICK && +/\<[a-zA-Z0-9_]{3,16}(\+\+|--)/ { + say("#rhnoise", "(" DST ") " FROM ": " MSG); +} + +# Fun operators +function bang(a, b) { + if (a=="nan") return "nan"; + if (b=="nan") return "nan"; + if (a==b) return "nan"; + if (a==0) return "+0"; + if (b==0) return "-0"; + return 1/(1/a - 1/b); +} + +/^ *[+-]?[0-9]*\.?[0-9]+( *\? *[+-]?[0-9]*\.?[0-9]+)+ *$/ { + gsub(/?/, " "); + _num = $1+0; + for (_i=2; _i<=NF; _i++) + _num = bang(_num, $_i+0); + reply(_num); +} + # Misc { fflush("") }