Class: EnerbotSlack

Inherits:
Credentials show all
Includes:
SlackFormat, SlackImage, SlackMessage, SlackRealTime, SlackSearch
Defined in:
lib/enerbot-slack.rb

Overview

Groups client initialization with instance parameters

Instance Method Summary collapse

Methods included from SlackSearch

#conversation_info, #conversation_list, #conversation_members, #conversation_permalink, #conversation_replies, #conversation_type, #get_user_id, #get_user_info, #get_user_list, #search_messages_on, #verify_type

Methods included from SlackClient

#configure_client

Methods included from SlackFormat

#attachment_style, #channel_pattern, #coin_pattern, #hyper_text_pattern

Methods included from SlackImage

#event_look_revert, #event_look_set, #imitate_look

Methods included from SlackMessage

#add_reaction, #destination_points, #send_attachment, #send_command, #send_direct_message, #send_ephemeral, #send_file, #send_message

Methods included from SlackRealTime

#share_message, #single_client

Methods included from SlackConsole

#format_new_message

Methods inherited from Credentials

#set_defaults

Constructor Details

#initialize(name: '', image: '', token: nil, as_user: false) ⇒ EnerbotSlack

Returns a new instance of EnerbotSlack.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/enerbot-slack.rb', line 17

def initialize(name: '', image: '', token: nil, as_user: false)
  set_defaults

  Slack.configure do |config|
    config.token = token.nil? ? @bot_token : token
    config.raise 'Missing token' unless config.token
  end

  @bot_name = name unless name.empty?
  @bot_icon = image unless image.empty?
  @bot_user = as_user

  @time_client ||= Slack::RealTime::Client.new
  @web_client ||= Slack::Web::Client.new
end