]> Pileus Git - ~andy/rhawk/blobdiff - rhawk
Change order of error messages
[~andy/rhawk] / rhawk
diff --git a/rhawk b/rhawk
index 2b8370613db042c7d3377cc1b861156e9828ac84..bb9c032906999d2fe5dceebacbc2efde7c272aa8 100755 (executable)
--- a/rhawk
+++ b/rhawk
@@ -3,7 +3,7 @@
 @include "irc.awk"
 @include "json.awk"
 @include "spades.awk"
-#@include "email.awk"
+@include "email.awk"
 
 # Initialization
 BEGIN {
@@ -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" }
@@ -318,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" &&
@@ -326,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!")
 }
@@ -400,6 +426,7 @@ FROM == "rhnoise" && load_mod {
 # Decrementer
 BEGIN {
        user_scores[0] = 1;
+       delete user_scores
 }
 
 /^\.(scores|scoreboard)$/ {
@@ -434,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("") }