Module: Twibot::Macros
- Defined in:
- lib/twibot/macros.rb
Class Method Summary collapse
Instance Method Summary collapse
- #configure(&blk) ⇒ Object
- #message(pattern = nil, options = {}, &blk) ⇒ Object
- #post_reply(status, msg) ⇒ Object
- #post_tweet(msg) ⇒ Object
- #reply(pattern = nil, options = {}, &blk) ⇒ Object
- #run? ⇒ Boolean
- #tweet(pattern = nil, options = {}, &blk) ⇒ Object
- #twitter ⇒ Object (also: #client)
Class Method Details
.included(mod) ⇒ Object
9 10 11 |
# File 'lib/twibot/macros.rb', line 9 def self.included(mod) @@bot = nil end |
Instance Method Details
#configure(&blk) ⇒ Object
13 14 15 |
# File 'lib/twibot/macros.rb', line 13 def configure(&blk) bot.configure(&blk) end |
#message(pattern = nil, options = {}, &blk) ⇒ Object
17 18 19 |
# File 'lib/twibot/macros.rb', line 17 def (pattern = nil, = {}, &blk) add_handler(:message, pattern, , &blk) end |
#post_reply(status, msg) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/twibot/macros.rb', line 41 def post_reply(status, msg) text = msg.respond_to?(:text) ? msg.text : msg reply_to_screen_name = status.user.screen_name reply_to_status_id = status.id = "@#{reply_to_screen_name} #{text}" puts client.status(:reply, , reply_to_status_id) end |
#post_tweet(msg) ⇒ Object
35 36 37 38 39 |
# File 'lib/twibot/macros.rb', line 35 def post_tweet(msg) = msg.respond_to?(:text) ? msg.text : msg puts client.status(:post, ) end |
#reply(pattern = nil, options = {}, &blk) ⇒ Object
21 22 23 |
# File 'lib/twibot/macros.rb', line 21 def reply(pattern = nil, = {}, &blk) add_handler(:reply, pattern, , &blk) end |
#run? ⇒ Boolean
50 51 52 |
# File 'lib/twibot/macros.rb', line 50 def run? !@@bot.nil? end |
#tweet(pattern = nil, options = {}, &blk) ⇒ Object
25 26 27 |
# File 'lib/twibot/macros.rb', line 25 def tweet(pattern = nil, = {}, &blk) add_handler(:tweet, pattern, , &blk) end |
#twitter ⇒ Object Also known as: client
29 30 31 |
# File 'lib/twibot/macros.rb', line 29 def twitter bot.twitter end |