Skip to content

Instantly share code, notes, and snippets.

@rjp
Created September 2, 2010 10:11
Show Gist options
  • Save rjp/562120 to your computer and use it in GitHub Desktop.
Save rjp/562120 to your computer and use it in GitHub Desktop.
# 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