Created
September 2, 2010 10:11
-
-
Save rjp/562120 to your computer and use it in GitHub Desktop.
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
# ruby buzzwords.rb rjp 'lemons|walken|flange' | |
require 'UAClient' | |
class WordBot < UAClient | |
def announce_message_add(x) | |
if x['fromname'] == $who then | |
if x['subject'] =~ $regex then | |
puts $who.capitalize + " mentioned our buzzwords" | |
else # maybe in the body | |
request("message_list", { 'messageid' => x['messageid'] }) | |
end | |
end | |
end | |
def reply_message_list(x) | |
m = x.getChild('message') | |
content = m['text'] | |
if content =~ $regex then | |
puts $who.capitalize + " mentioned our buzzwords" | |
end | |
end | |
end | |
$who, matches = ARGV | |
$regex = %r{(\W|\A)(#{matches})(\W|\Z)}i | |
# use the test ua server with a shadow login | |
wordbot = WordBot.new("ua2.org", 2020, {:shadow => 256 }) | |
wordbot.start('username', 'password') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment