]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blob - data/rbot/plugins/threat.rb
AUTHORS update.
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / threat.rb
1 # Security threat level plugin for rbot
2 # by Robin Kearney (robin@riviera.org.uk)
3 #
4 # inspired by elliots fascination with the us
5 # threat level.
6 #
7 # again a dirty hack but it works, just...
8 #
9
10 require 'uri/common'
11
12 class ThreatPlugin < Plugin
13
14   def help(plugin, topic="")
15     "threat => prints out the current threat level as reported by http://www.dhs.gov/"
16   end
17
18   def privmsg(m)
19         color = ""
20     red = "\x0304" # severe
21         orange = "\x0307" # high
22         yellow = "\x0308" # elevated
23         blue = "\x0312" # guarded
24         green = "\x0303" # low
25         black = "\x0301" # default
26
27         page = @bot.httputil.get URI.parse("http://www.dhs.gov/dhspublic/")
28         if page =~ / <img.*dhs\/images\/dhs-advisory-(.*).gif.*/
29       state = $1
30     end
31     case state
32       when "severe"
33                 color = red
34       when "high"
35                 color = orange
36       when "elevated"
37                 color = yellow
38       when "guarded"
39                 color = blue
40       when "low"
41                 color = green
42         else
43           color = black
44         end
45
46         m.reply color + "Today " + m.sourcenick + " the threat level is " + state.capitalize
47
48         return
49   end
50
51 end
52 plugin = ThreatPlugin.new
53 plugin.register("threat")
54
55