Skip to content

Instantly share code, notes, and snippets.

@naoto
Created November 27, 2009 00:57
Show Gist options
  • Save naoto/243756 to your computer and use it in GitHub Desktop.
Save naoto/243756 to your computer and use it in GitHub Desktop.
Citrus Plugin - Twitter twit -
require 'open-uri'
require 'hpricot'
class Twitter < Citrus::Plugin
def on_privmsg(prefix, channel, message)
if /#{@config["prefix"]}/ =~ message
user = $2
html = Hpricot(open("http://twitter.com/#{user}"))
twit = html.search(".entry-content").first
if !twit.nil?
twit = "@#{user}: #{twit.inner_text}"
else
twit = html.search("h1.logged-out").first
if twit.nil?
twit = "だれそれ"
else
twit = twit.inner_text
end
end
notice(channel, twit)
end
rescue
notice(channel,"だれそれ")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment