Class: SlackRubyBot::Client

Inherits:
Slack::RealTime::Client
  • Object
show all
Defined in:
lib/slack-ruby-bot/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Client

Returns a new instance of Client.



7
8
9
10
11
# File 'lib/slack-ruby-bot/client.rb', line 7

def initialize(attrs = {})
  super(attrs)
  @aliases = attrs[:aliases]
  @send_gifs = attrs.key?(:send_gifs) ? !!attrs[:send_gifs] : true
end

Instance Attribute Details

#aliasesObject

Returns the value of attribute aliases.



4
5
6
# File 'lib/slack-ruby-bot/client.rb', line 4

def aliases
  @aliases
end

#authObject

Returns the value of attribute auth.



3
4
5
# File 'lib/slack-ruby-bot/client.rb', line 3

def auth
  @auth
end

#send_gifsObject

Returns the value of attribute send_gifs.



5
6
7
# File 'lib/slack-ruby-bot/client.rb', line 5

def send_gifs
  @send_gifs
end

Instance Method Details

#nameObject



36
37
38
# File 'lib/slack-ruby-bot/client.rb', line 36

def name
  SlackRubyBot.config.user || (auth && auth['user'])
end

#name?(name) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/slack-ruby-bot/client.rb', line 28

def name?(name)
  name && names.include?(name.downcase)
end

#namesObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/slack-ruby-bot/client.rb', line 13

def names
  [
    SlackRubyBot::Config.user,
    auth ? auth['user'] : nil,
    aliases,
    SlackRubyBot::Config.aliases,
    auth ? "<@#{auth['user_id'].downcase}>" : nil,
    SlackRubyBot::Config.user_id ? "<@#{SlackRubyBot::Config.user_id.downcase}>" : nil,
    auth ? "<@#{auth['user_id'].downcase}>:" : nil,
    SlackRubyBot::Config.user_id ? "<@#{SlackRubyBot::Config.user_id.downcase}>:" : nil,
    auth ? "#{auth['user']}:" : nil,
    SlackRubyBot::Config.user ? "#{SlackRubyBot::Config.user}:" : nil
  ].compact.flatten
end

#send_gifs?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/slack-ruby-bot/client.rb', line 32

def send_gifs?
  send_gifs
end

#urlObject



40
41
42
# File 'lib/slack-ruby-bot/client.rb', line 40

def url
  SlackRubyBot.config.url || (auth && auth['url'])
end