class BotMob::Networks::Slack::Connection
# BotMob::Networks::Slack::Connection
Handles all the connection details between a bot and Slack
Attributes
bot[R]
token[R]
Public Class Methods
new(bot, options = {})
click to toggle source
# File lib/bot_mob/networks/slack/connection.rb, line 10 def initialize(bot, options = {}) @bot = bot @token = options[:token] raise BotMob::NetworkConnectionError, 'Slack connection requires a :token parameter' if @token.nil? end
Public Instance Methods
client()
click to toggle source
# File lib/bot_mob/networks/slack/connection.rb, line 27 def client @client ||= begin client = ::Slack::Web::Client.new(token: token) client.auth_test client end end
deliver(outbound_message, options = {})
click to toggle source
# File lib/bot_mob/networks/slack/connection.rb, line 16 def deliver(outbound_message, options = {}) BotMob.logger.info(" Sending to Slack: \"#{options.inspect}\"\n") BotMob.logger.info(" Text: \"#{outbound_message.body.inspect}\"\n") client.chat_postMessage( channel: outbound_message.channel, text: outbound_message.body, as_user: true ) end