Module: Twibot::Macros

Defined in:
lib/twibot/macros.rb

Class Method Summary collapse

Instance Method Summary collapse

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 message(pattern = nil, options = {}, &blk)
  add_handler(:message, pattern, options, &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
  message = "@#{reply_to_screen_name} #{text}"
  puts message
  client.status(:reply, message, 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)
  message = msg.respond_to?(:text) ? msg.text : msg
  puts message
  client.status(:post, message)
end

#reply(pattern = nil, options = {}, &blk) ⇒ Object



21
22
23
# File 'lib/twibot/macros.rb', line 21

def reply(pattern = nil, options = {}, &blk)
  add_handler(:reply, pattern, options, &blk)
end

#run?Boolean

Returns:

  • (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, options = {}, &blk)
  add_handler(:tweet, pattern, options, &blk)
end

#twitterObject Also known as: client



29
30
31
# File 'lib/twibot/macros.rb', line 29

def twitter
  bot.twitter
end