Permalink
Browse files

Added a usage to tweet to display the latest tweet by a given username.

  • Loading branch information...
1 parent a6e338e commit b4851f26ab1e9016c0bd3412a72cd5c707239f3b @LindseyB committed Mar 14, 2012
Showing with 10 additions and 2 deletions.
  1. +10 −2 lib/xombot/plugins/tweet.rb
@@ -1,10 +1,18 @@
class Tweet < XOmBot::Plugin
- match /tweet (\d+)/
+ match /tweet (\d+)/, :method => :tweet_by_id
help "Displays the tweet with the given id"
usage "tweet 12345678 -- displays the twitter update with that id"
+
+ match /tweet (\w.*)/, :method => :tweet_by_username
+ help "Displays the latest tweet by the given user"
+ usage "tweet noob -- displays the last tweet by noob"
- def execute(m, id)
+ def tweet_by_id(m, id)
status = Twitter.status(id)
m.reply "@#{status.user.screen_name}: #{status.text}"
end
+
+ def tweet_by_username(m, username)
+ m.reply "@#{username}: #{Twitter.user_timeline(username).first.text}"
+ end
end

0 comments on commit b4851f2

Please sign in to comment.