summaryrefslogtreecommitdiff
path: root/data/rbot/plugins/threat.rb
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-10-19 21:52:10 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-10-19 21:52:10 +0000
commit676b3fb7fddc8d35b3ae20c59f4a3ddd7b4039c5 (patch)
tree551bc0e147f7665223a5e3e0459698c371b252e3 /data/rbot/plugins/threat.rb
parent0848deafbc14e15e4fd6e08cfb767fa56045c202 (diff)
Update threat plugin to new DHS site layout, and make it more robust
Diffstat (limited to 'data/rbot/plugins/threat.rb')
-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