Skip to content

Instantly share code, notes, and snippets.

@aytch
Created February 8, 2013 18:26
Show Gist options
  • Select an option

  • Save aytch/4740933 to your computer and use it in GitHub Desktop.

Select an option

Save aytch/4740933 to your computer and use it in GitHub Desktop.
on :message, /https?:\/\/twitter\.com\/(?:#!\/)?(\w+)\/status(es)?\/(\d+)/i do |m, message|
url = message.to_s
doc = Nokogiri::HTML(open(url))
user = doc.at_css("span.username.js-action-profile-name b").text
status = doc.xpath("//div[3]/div/div/div/div/p").text[/\S(.+)/]
message = "Twitter | @#{user}: #{status}"
m.reply message
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment