Class: SlackRubyBot::Client
- Inherits:
-
Slack::RealTime::Client
- Object
- Slack::RealTime::Client
- SlackRubyBot::Client
- Includes:
- Loggable
- Defined in:
- lib/slack-ruby-bot/client.rb
Instance Attribute Summary collapse
-
#aliases ⇒ Object
Returns the value of attribute aliases.
-
#allow_bot_messages ⇒ Object
Returns the value of attribute allow_bot_messages.
-
#allow_message_loops ⇒ Object
Returns the value of attribute allow_message_loops.
Instance Method Summary collapse
- #allow_bot_messages? ⇒ Boolean
- #allow_message_loops? ⇒ Boolean
- #bot_message?(data) ⇒ Boolean
-
#initialize(attrs = {}) ⇒ Client
constructor
A new instance of Client.
- #message_to_self?(data) ⇒ Boolean
- #name ⇒ Object
- #name?(name) ⇒ Boolean
- #names ⇒ Object
- #say(options = {}) ⇒ Object
- #url ⇒ Object
Methods included from Loggable
Constructor Details
#initialize(attrs = {}) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 15 |
# File 'lib/slack-ruby-bot/client.rb', line 10 def initialize(attrs = {}) super(attrs) @aliases = attrs[:aliases] @allow_message_loops = attrs[:allow_message_loops] @allow_bot_messages = attrs[:allow_bot_messages] end |
Instance Attribute Details
#aliases ⇒ Object
Returns the value of attribute aliases.
6 7 8 |
# File 'lib/slack-ruby-bot/client.rb', line 6 def aliases @aliases end |
#allow_bot_messages ⇒ Object
Returns the value of attribute allow_bot_messages.
7 8 9 |
# File 'lib/slack-ruby-bot/client.rb', line 7 def @allow_bot_messages end |
#allow_message_loops ⇒ Object
Returns the value of attribute allow_message_loops.
8 9 10 |
# File 'lib/slack-ruby-bot/client.rb', line 8 def @allow_message_loops end |
Instance Method Details
#allow_bot_messages? ⇒ Boolean
21 22 23 |
# File 'lib/slack-ruby-bot/client.rb', line 21 def @allow_bot_messages.nil? ? SlackRubyBot::Config. : !!@allow_bot_messages end |
#allow_message_loops? ⇒ Boolean
17 18 19 |
# File 'lib/slack-ruby-bot/client.rb', line 17 def @allow_message_loops.nil? ? SlackRubyBot::Config. : !!@allow_message_loops end |
#bot_message?(data) ⇒ Boolean
29 30 31 |
# File 'lib/slack-ruby-bot/client.rb', line 29 def (data) data.subtype == 'bot_message' end |
#message_to_self?(data) ⇒ Boolean
25 26 27 |
# File 'lib/slack-ruby-bot/client.rb', line 25 def (data) !!(self.self && self.self.id == data.user) end |
#name ⇒ Object
52 53 54 |
# File 'lib/slack-ruby-bot/client.rb', line 52 def name SlackRubyBot.config.user || self.self&.name end |
#name?(name) ⇒ Boolean
48 49 50 |
# File 'lib/slack-ruby-bot/client.rb', line 48 def name?(name) name && names.include?(name.downcase) end |
#names ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/slack-ruby-bot/client.rb', line 33 def names [ SlackRubyBot::Config.user, self.self ? self.self.name : nil, aliases ? aliases.map(&:downcase) : nil, SlackRubyBot::Config.aliases ? SlackRubyBot::Config.aliases.map(&:downcase) : nil, self.self && self.self.id ? "<@#{self.self.id.downcase}>" : nil, SlackRubyBot::Config.user_id ? "<@#{SlackRubyBot::Config.user_id.downcase}>" : nil, self.self && self.self.id ? "<@#{self.self.id.downcase}>:" : nil, SlackRubyBot::Config.user_id ? "<@#{SlackRubyBot::Config.user_id.downcase}>:" : nil, self.self && self.self.name ? "#{self.self.name.downcase}:" : nil, SlackRubyBot::Config.user ? "#{SlackRubyBot::Config.user}:" : nil ].compact.flatten end |
#say(options = {}) ⇒ Object
60 61 62 63 |
# File 'lib/slack-ruby-bot/client.rb', line 60 def say( = {}) logger.warn '[DEPRECATION] `gif:` is deprecated and has no effect.' if .key?(:gif) ({ text: '' }.merge()) end |
#url ⇒ Object
56 57 58 |
# File 'lib/slack-ruby-bot/client.rb', line 56 def url SlackRubyBot.config.url || super end |