]> Pileus Git - ~andy/rhawk/blobdiff - rhawk
Add URL to .version
[~andy/rhawk] / rhawk
diff --git a/rhawk b/rhawk
index 713c7995b267806f457b5a142ae3447faa0955fa..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"];
 
@@ -160,13 +160,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 +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" }
@@ -202,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["/"      ] = " "
@@ -308,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" &&
@@ -316,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!")
 }
@@ -390,6 +426,7 @@ FROM == "rhnoise" && load_mod {
 # Decrementer
 BEGIN {
        user_scores[0] = 1;
+       delete user_scores
 }
 
 /^\.(scores|scoreboard)$/ {
@@ -424,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("") }