summaryrefslogtreecommitdiff
path: root/data/rbot
diff options
context:
space:
mode:
authorTom Gilbert <tom@linuxbrit.co.uk>2005-08-10 23:12:50 +0000
committerTom Gilbert <tom@linuxbrit.co.uk>2005-08-10 23:12:50 +0000
commit8db3c907730752ccc668c69080680d1b90140c10 (patch)
treec080db6ea30f2a923a5ff809682791d558d9f046 /data/rbot
parent61778ca75f9659c1482284ee0cc56178928044d8 (diff)
AUTHORS update.
Added two plugins from Robin Kearney <robin@riviera.org.uk>
Diffstat (limited to 'data/rbot')
-rw-r--r--data/rbot/plugins/bash.rb56
-rw-r--r--data/rbot/plugins/karma.rb2
-rw-r--r--data/rbot/plugins/lart.rb2
-rw-r--r--data/rbot/plugins/threat.rb55
4 files changed, 113 insertions, 2 deletions
diff --git a/data/rbot/plugins/bash.rb b/data/rbot/plugins/bash.rb
new file mode 100644
index 00000000..6f954a16
--- /dev/null
+++ b/data/rbot/plugins/bash.rb
@@ -0,0 +1,56 @@
+# bash.org xml plugin for rbot
+# by Robin Kearney (robin@riviera.org.uk)
+#
+# its a bit of a quick hack, but it works for us :)
+#
+require 'rexml/document'
+require 'uri/common'
+
+class BashPlugin < Plugin
+ include REXML
+ def help(plugin, topic="")
+ "bash => print a random quote from bash.org, bash quote_id => print that quote id from bash.org, bash latest => print the latest quote from bash.org (currently broken, need to get josh@bash.org to fix the xml)"
+ end
+ def privmsg(m)
+ if m.params && m.params =~ /^([-\d]+)$/
+ id = $1
+ bash m, id
+ elsif(m.params == "latest")
+ bash m, id
+ else
+ bash m
+ end
+ end
+
+ def bash(m, id=0)
+
+ if(id != 0)
+ xml = @bot.httputil.get URI.parse("http://bash.org/xml/?" + id + "&num=1")
+ elsif(id == "latest")
+ xml = @bot.httputil.get URI.parse("http://bash.org/xml/?latest&num=1")
+ else
+ xml = @bot.httputil.get URI.parse("http://bash.org/xml/?random&num=1")
+ end
+ unless xml
+ m.reply "bash.org rss parse failed"
+ return
+ end
+ doc = Document.new xml
+ unless doc
+ m.reply "bash.org rss parse failed"
+ return
+ end
+ doc.elements.each("*/item") {|e|
+ if(id != 0)
+ reply = e.elements["title"].text.gsub(/QDB: /,"") + " " + e.elements["link"].text.gsub(/QDB: /,"") + "\n"
+ reply = reply + e.elements["description"].text.gsub(/\<br \/\>/, "\n")
+ else
+ reply = e.elements["title"].text.gsub(/QDB: /,"") + " " + e.elements["link"].text.gsub(/QDB: /,"") + "\n"
+ reply = reply + e.elements["description"].text.gsub(/\<br \/\>/, "\n")
+ end
+ m.reply reply
+ }
+ end
+end
+plugin = BashPlugin.new
+plugin.register("bash")
diff --git a/data/rbot/plugins/karma.rb b/data/rbot/plugins/karma.rb
index 148427a5..824ffa95 100644
--- a/data/rbot/plugins/karma.rb
+++ b/data/rbot/plugins/karma.rb
@@ -52,7 +52,7 @@ class KarmaPlugin < Plugin
def help(plugin, topic="")
- "karma module: <thing>++/<thing>-- => increase/decrease karma for <thing>, karma for <thing>? => show karma for <thing>, karmastats => show stats. Karma is a community rating system - only in-channel messages can affect karma and you cannot adjust your own."
+ "karma module: Listens to everyone's chat. <thing>++/<thing>-- => increase/decrease karma for <thing>, karma for <thing>? => show karma for <thing>, karmastats => show stats. Karma is a community rating system - only in-channel messages can affect karma and you cannot adjust your own."
end
def listen(m)
return unless m.kind_of?(PrivMessage) && m.public?
diff --git a/data/rbot/plugins/lart.rb b/data/rbot/plugins/lart.rb
index de767197..54c335af 100644
--- a/data/rbot/plugins/lart.rb
+++ b/data/rbot/plugins/lart.rb
@@ -78,7 +78,7 @@ class LartPlugin < Plugin
#}}}
#{{{
def help(plugin, topic="")
- "Lart: The lart plugin allows you to punish/praise someone in the channel. You can also add new punishments and new praises as well as delete them. For the curious, LART is an acronym for Luser Attitude Readjustment Tool.\nUsage: punish/lart <nick> <reason> -- punishes <nick> for <reason>. The reason is optional.\n praise <nick> <reason> -- praises <nick> for <reason>. The reason is optional.\n mod[lart|punish|praise] [add|remove] -- Add or remove a lart or praise."
+ "Lart: The lart plugin allows you to punish/praise someone in the channel. You can also add new punishments and new praises as well as delete them. For the curious, LART is an acronym for Luser Attitude Readjustment Tool. Usage: punish/lart <nick> [<reason>] -- punishes <nick> for <reason>. praise <nick> [<reason>] -- praises <nick> for <reason>. [add|rm][lart|punish|praise] -- Add or remove a lart or praise."
end
#}}}
# The following are command handlers {{{
diff --git a/data/rbot/plugins/threat.rb b/data/rbot/plugins/threat.rb
new file mode 100644
index 00000000..ae709101
--- /dev/null
+++ b/data/rbot/plugins/threat.rb
@@ -0,0 +1,55 @@
+# Security threat level plugin for rbot
+# by Robin Kearney (robin@riviera.org.uk)
+#
+# inspired by elliots fascination with the us
+# threat level.
+#
+# again a dirty hack but it works, just...
+#
+
+require 'uri/common'
+
+class ThreatPlugin < Plugin
+
+ def help(plugin, topic="")
+ "threat => prints out the current threat level as reported by http://www.dhs.gov/"
+ end
+
+ def privmsg(m)
+ 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.*/
+ state = $1
+ end
+ case state
+ when "severe"
+ color = red
+ when "high"
+ color = orange
+ when "elevated"
+ color = yellow
+ when "guarded"
+ color = blue
+ when "low"
+ color = green
+ else
+ color = black
+ end
+
+ m.reply color + "Today " + m.sourcenick + " the threat level is " + state.capitalize
+
+ return
+ end
+
+end
+plugin = ThreatPlugin.new
+plugin.register("threat")
+
+