]> Pileus Git - ~andy/rhawk/blobdiff - rhawk
Remove pretty formatting from email messages
[~andy/rhawk] / rhawk
diff --git a/rhawk b/rhawk
index b31fac2db501d814eaf20a63bfd0d67387c1356a..bb9c032906999d2fe5dceebacbc2efde7c272aa8 100755 (executable)
--- a/rhawk
+++ b/rhawk
@@ -3,13 +3,13 @@
 @include "irc.awk"
 @include "json.awk"
 @include "spades.awk"
-#@include "email.awk"
+@include "email.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,7 +22,7 @@ BEGIN {
        delete login
 
        if (FIRST) {
-               join("#rhnoise")
+               join("#rhtest")
                join("#rhspades")
                join("#sfvlug")
        }
@@ -145,6 +145,11 @@ BEGIN { pollchan = "#sfvlug" }
 }
 
 # Versin/Uptime
+function head(cmd, var) {
+       cmd | getline var
+       close(cmd)
+       return var
+}
 function uptime(time,  fmt) {
        fmt = "%d:%02d:%02d:%02d"
        fmt = "%d days %02d:%02d:%02d"
@@ -155,13 +160,15 @@ function uptime(time,  fmt) {
                time / (1       ) % 60)
 }
 BEGIN {
-       _cmd = "git describe --always --dirty";
-       _cmd | getline up_version;
-       close(_cmd);
-       up_reload = systime();
+       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/ {
-       say("version: " up_version)
+/^\.(version|rev)/ {
+       say("version: " up_dirty " - " up_author " - " up_message)
+       say("http://pileus.org/git/?p=~andy/rhawk;h=" up_version)
 }
 /^\.uptime/ {
        _now = systime();
@@ -182,6 +189,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" }
@@ -197,6 +229,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["/"      ] = " "
@@ -303,6 +345,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" &&
@@ -311,12 +358,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!")
 }
@@ -344,6 +385,15 @@ FROM == "rhnoise" && $2 == "slaps" && $3 == NICK {
        say("THE LARCH");
 }
 
+/(for what|that for)\?$/ {
+       say("For great justice!");
+}
+
+/\<nazi/ {
+       say("And now it's...");
+       say("Springtime for Hitler and Germany!");
+}
+
 # God damn commands
 FROM == "rhnoise" && load_mod {
        say(".load " load_mod)
@@ -376,6 +426,7 @@ FROM == "rhnoise" && load_mod {
 # Decrementer
 BEGIN {
        user_scores[0] = 1;
+       delete user_scores
 }
 
 /^\.(scores|scoreboard)$/ {
@@ -410,6 +461,11 @@ tolower($0) ~ /\<nuclear launch detected\>/ {
        }
 }
 
+# Vote relay
+DST != "#rhnoise" && /\<[a-zA-Z0-9_]{3,16}(\+\+|--)/ {
+       say("#rhnoise", "(" DST ") " FROM ": " MSG);
+}
+
 # Misc
 { fflush("") }