Created
April 26, 2009 00:58
-
-
Save sorah/101826 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-*- | |
require "open-uri" | |
require "uri" | |
require "kconv" | |
#Twitterのステータスのpermalinkを渡すと「id: 内容」とpost内容を返します。なにげに便利 | |
class TwitterBot < Nadoka::NDK_Bot | |
def on_privmsg prefix, ch, msg | |
if /^http:\/\/twitter.com\/(.+)\/(statuses|status)\/.+\/?$/ =~ msg | |
id = $1 | |
twit_html = "" | |
open(msg) {|h| | |
h.each_line{|n| | |
twit_html += n | |
} | |
} | |
if /<span class="entry-content">(.+)<\/span><span class="meta entry-meta">/ =~ twit_html | |
send_notice(ch,"#{id}: "+$1.tojis) | |
else | |
send_notice(ch,"twitterbot: error!") | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment