lib/ruboty/adapters/slack_rtm.rb in ruboty-slack_rtm-1.3.1 vs lib/ruboty/adapters/slack_rtm.rb in ruboty-slack_rtm-1.4.0

- old
+ new

@@ -7,10 +7,11 @@ module Ruboty module Adapters class SlackRTM < Base env :SLACK_TOKEN, "Account's token. get one on https://api.slack.com/web#basics" env :SLACK_EXPOSE_CHANNEL_NAME, "if this set to 1, message.to will be channel name instead of id", optional: true + env :SLACK_IGNORE_GENERAL, "if this set to 1, bot ignores all messages on #general channel", optional: true def run init bind connect @@ -92,10 +93,13 @@ def on_message(data) data = resolve_mention!(data) user = user_info(data['user']) || {} channel = channel_info(data['channel']) + if channel + return if channel['name'] == 'general' && ENV['SLACK_IGNORE_GENERAL'] == '1' + channel_to = expose_channel_name? ? "##{channel['name']}" : channel['id'] else # direct message channel_to = data['channel'] end