-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added two plugins from Robin Kearney <robin@riviera.org.uk>
- Loading branch information
Showing
7 changed files
with
130 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
|
||
|