Class: FuckBot::MessageResolver
- Inherits:
-
Object
- Object
- FuckBot::MessageResolver
- Defined in:
- lib/fuck_bot/message_resolver.rb
Constant Summary collapse
- BAD_WORD_RESPONSE =
"Watch your language, <@%s>! «%s» is a bad word!".freeze
Instance Method Summary collapse
- #bad ⇒ Object
- #call ⇒ Object
-
#initialize(data, client) ⇒ MessageResolver
constructor
A new instance of MessageResolver.
- #ping ⇒ Object
- #stats ⇒ Object
Constructor Details
#initialize(data, client) ⇒ MessageResolver
Returns a new instance of MessageResolver.
8 9 10 11 |
# File 'lib/fuck_bot/message_resolver.rb', line 8 def initialize(data, client) @data = data @client = client end |
Instance Method Details
#bad ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/fuck_bot/message_resolver.rb', line 13 def bad found_bad_word = find_bad_word return unless found_bad_word @client.store.increment(@data['user']).save send_response( format(BAD_WORD_RESPONSE, @data['user'], found_bad_word) ) end |
#call ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/fuck_bot/message_resolver.rb', line 37 def call return unless && !self? rules.each do |rule| break if public_send(rule) end end |
#ping ⇒ Object
31 32 33 34 35 |
# File 'lib/fuck_bot/message_resolver.rb', line 31 def ping return unless ping? send_response(:pong) end |
#stats ⇒ Object
25 26 27 28 29 |
# File 'lib/fuck_bot/message_resolver.rb', line 25 def stats return unless stats? send_response(@client.store.to_stats) end |