Class: BotMob::Bot

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/bot_mob/bot.rb

Overview

## BotMob::Bot

This is the base for all bots that will connect to Slack.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(external_id, token) ⇒ Bot

Returns a new instance of Bot.



14
15
16
17
# File 'lib/bot_mob/bot.rb', line 14

def initialize(external_id, token)
  @external_id = external_id
  @token = token
end

Instance Attribute Details

#external_idObject (readonly)

Returns the value of attribute external_id.



9
10
11
# File 'lib/bot_mob/bot.rb', line 9

def external_id
  @external_id
end

Instance Method Details

#api_post(args = {}) ⇒ Object



19
20
21
22
# File 'lib/bot_mob/bot.rb', line 19

def api_post(args = {})
  BotMob.logger.info("  Sending \"#{args.inspect}\"\n")
  client.web_client.chat_postMessage(args)
end

#connectionObject



37
38
39
# File 'lib/bot_mob/bot.rb', line 37

def connection
  @connection ||= BotMob::Connection.new(:slack, self, @token)
end

#realtime_post(args = {}) ⇒ Object



24
25
26
27
# File 'lib/bot_mob/bot.rb', line 24

def realtime_post(args = {})
  BotMob.logger.info("  Sending \"#{args[:text]}\"\n")
  client.message(args)
end

#respond(message) ⇒ Object



29
30
31
# File 'lib/bot_mob/bot.rb', line 29

def respond(message)
  # noop
end

#respond?(message) ⇒ Boolean

Returns:



33
34
35
# File 'lib/bot_mob/bot.rb', line 33

def respond?(message)
  false
end