Permalink
Browse files

Adds ability for Tweet plugin to be invoked on a twitter url.

  • Loading branch information...
1 parent ca55461 commit 9caed9437360149c06cd135b373eaae2bdae792f @wilkie wilkie committed Oct 14, 2012
Showing with 15 additions and 1 deletion.
  1. +15 −1 lib/xombot/plugins/tweet.rb
@@ -7,12 +7,26 @@ class Tweet < XOmBot::Plugin
help "Displays the latest tweet by the given user"
usage "tweet noob -- displays the last tweet by noob"
+ def setup
+ url_plugin = XOmBot.plugins["URLAnnounce"]
+ if url_plugin
+ url_plugin.match_domain("twitter.com") do |m, url|
+ tweet_by_url m, url
+ end
+ end
+ end
+
def tweet_by_id(m, id)
status = Twitter.status(id)
m.reply "@#{status.user.screen_name}: #{HTMLEntities.new.decode status.text}"
end
def tweet_by_username(m, username)
- m.reply "@#{username}: #{HTMLEntities.new.decode Twitter.user_timeline(username).first.text}"
+ m.reply "@#{username}: #{HTMLEntities.new.decode Twitter.user_timeline(username).first.text}"
+ end
+
+ def tweet_by_url(m, url)
+ id = url[/^https?:\/\/.*\/status\/(\d+)/,1]
+ tweet_by_id m, id
end
end

0 comments on commit 9caed94

Please sign in to comment.