Sha256: 13eef4f939b82fc4dbf9427a1d00ccc0afbc1c49687095fefb8c250602456a3c
Contents?: true
Size: 981 Bytes
Versions: 1
Compression:
Stored size: 981 Bytes
Contents
# frozen_string_literal: true SlackRubyBotServer::Events.configure do |config| config.on :event, 'event_callback', 'app_mention' do |event| data = event['event'] next unless data team = Team.where(team_id: event['team_id']).first next unless team bot_regexp = Regexp.new("^\<\@#{team.bot_user_id}\>[[:space:]]*") data = Slack::Messages::Message.new(data).merge( text: data['text'].gsub(bot_regexp, ''), team: team ) SlackRubyBotServer::Events::AppMentions.config.handlers.detect { |c| c.invoke(data) } end config.on :event, 'event_callback', 'message' do |event| data = event['event'] next unless data # direct message only next unless data['channel_type'] == 'im' team = Team.where(team_id: event['team_id']).first next unless team data = Slack::Messages::Message.new(data).merge(team: team) SlackRubyBotServer::Events::AppMentions.config.handlers.detect { |c| c.invoke(data) } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
slack-ruby-bot-server-events-app-mentions-0.1.1 | lib/slack-ruby-bot-server-events-app-mentions/events.rb |