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

Instance Attribute Details

#authObject

Returns the value of attribute auth.



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

def auth
  @auth
end

Instance Method Details

#nameObject



23
24
25
# File 'lib/slack-ruby-bot/client.rb', line 23

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

#name?(name) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/slack-ruby-bot/client.rb', line 19

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

#namesObject



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/slack-ruby-bot/client.rb', line 5

def names
  [
    SlackRubyBot::Config.user,
    auth ? auth['user'] : nil,
    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

#urlObject



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

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