class Slappy::Event
Attributes
data[RW]
matches[RW]
Public Class Methods
new(data)
click to toggle source
# File lib/slappy/event.rb, line 10 def initialize(data) @data = Hashie::Mash.new data end
Public Instance Methods
bot_message?()
click to toggle source
# File lib/slappy/event.rb, line 43 def bot_message? @data['subtype'] && @data['subtype'] == 'bot_message' end
channel()
click to toggle source
# File lib/slappy/event.rb, line 18 def channel SlackAPI::Channel.find(id: @data['channel']) || SlackAPI::Group.find(id: @data['channel']) || SlackAPI::Direct.find(id: @data['channel']) end
reaction(emoji)
click to toggle source
# File lib/slappy/event.rb, line 38 def reaction(emoji) result = ::Slack.reactions_add name: emoji, channel: @data['channel'], timestamp: @data['ts'] Debug.log "Reaction response: #{result}" end
reply(text, options = {})
click to toggle source
# File lib/slappy/event.rb, line 32 def reply(text, options = {}) options[:text] = text options[:channel] = channel Messenger.new(options).message end
text()
click to toggle source
# File lib/slappy/event.rb, line 14 def text @data['text'].to_s end
ts()
click to toggle source
# File lib/slappy/event.rb, line 28 def ts Time.at((@data['ts'] || @data['event_ts']).to_f) end
user()
click to toggle source
# File lib/slappy/event.rb, line 24 def user SlackAPI::User.find(id: @data['user']) end