Created
November 27, 2009 00:57
-
-
Save naoto/243756 to your computer and use it in GitHub Desktop.
Citrus Plugin - Twitter twit -
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
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