Sha256: ac5b5abb971b5712eadc7937217983ad417708892f7a46a6baa154ba0b47f865
Contents?: true
Size: 1018 Bytes
Versions: 2
Compression:
Stored size: 1018 Bytes
Contents
module Slappy class Event extend Forwardable include Debuggable attr_accessor :matches, :data def_delegators :@data, :method_missing, :respond_to_missing? def initialize(data) @data = Hashie::Mash.new data end def text @data['text'].to_s end def channel SlackAPI::Channel.find(id: @data['channel']) || SlackAPI::Group.find(id: @data['channel']) || SlackAPI::Direct.find(id: @data['channel']) end def user SlackAPI::User.find(id: @data['user']) end def ts Time.at(@data['ts'].to_f) end def reply(text, options = {}) options[:text] = text options[:channel] = channel Messenger.new(options).message end def reaction(emoji) result = ::Slack.reactions_add name: emoji, channel: @data['channel'], timestamp: @data['ts'] Debug.log "Reaction response: #{result}" end def bot_message? @data['subtype'] && @data['subtype'] == 'bot_message' end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
slappy-0.6.2 | lib/slappy/event.rb |
slappy-0.6.1 | lib/slappy/event.rb |