summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/rbot/plugins/threat.rb47
1 files changed, 25 insertions, 22 deletions
diff --git a/data/rbot/plugins/threat.rb b/data/rbot/plugins/threat.rb
index ae709101..3784dafe 100644
--- a/data/rbot/plugins/threat.rb
+++ b/data/rbot/plugins/threat.rb
@@ -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 URI.parse("http://www.dhs.gov/")
+
+ 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