]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/threat.rb
script plugin: use m.okay
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / threat.rb
index ae7091010de2ef4852dc2dc423beef6842f9756f..dacd10584dd839ff545b8820dc01e6dc4627aa34 100644 (file)
@@ -16,36 +16,39 @@ class ThreatPlugin < Plugin
   end
 
   def privmsg(m)
-       color = ""
+    color = ""
     red = "\x0304" # severe
-       orange = "\x0307" # high
-       yellow = "\x0308" # elevated
-       blue = "\x0312" # guarded
-       green = "\x0303" # low
-       black = "\x0301" # default
-
-       page = @bot.httputil.get URI.parse("http://www.dhs.gov/dhspublic/")
-       if page =~ / <img.*dhs\/images\/dhs-advisory-(.*).gif.*/
+    orange = "\x0307" # high
+    yellow = "\x0308" # elevated
+    blue = "\x0312" # guarded
+    green = "\x0303" # low
+    black = "\x0301" # default
+
+    page = @bot.httputil.get("http://www.dhs.gov/index.shtm")
+
+    if page =~ /\"Current National Threat Level is (.*?)\"/
       state = $1
-    end
-    case state
+      case state
       when "severe"
-               color = red
+        color = red
       when "high"
-               color = orange
+        color = orange
       when "elevated"
-               color = yellow
+        color = yellow
       when "guarded"
-               color = blue
+        color = blue
       when "low"
-               color = green
-       else
-         color = black
-       end
-
-       m.reply color + "Today " + m.sourcenick + " the threat level is " + state.capitalize
+        color = green
+      else
+        color = black
+      end
+
+      m.reply color + "Today " + m.sourcenick + " the threat level is " + state.capitalize
+    else
+      m.reply "I was unable to retrieve the threat level"
+    end
 
-       return
+    return
   end
 
 end