Skip to content

Instantly share code, notes, and snippets.

@sorah
Created April 26, 2009 00:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sorah/101826 to your computer and use it in GitHub Desktop.
Save sorah/101826 to your computer and use it in GitHub Desktop.
# -*-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