Permalink
Browse files
Adds ability for Tweet plugin to be invoked on a twitter url.
- Loading branch information...
Showing
with
15 additions
and
1 deletion.
-
+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