lib/slack/smart-bot/treat_message.rb in slack-smart-bot-1.9.1 vs lib/slack/smart-bot/treat_message.rb in slack-smart-bot-1.9.2

- old
+ new

@@ -67,18 +67,28 @@ if !dest.nil? and config.on_master_bot and !data.text.nil? and data.text.match(/^ping from (.+)\s*$/) and data.user == config[:nick_id] @pings << $1 end typem = :dont_treat if !dest.nil? and !data.text.nil? and !data.text.to_s.match?(/\A\s*\z/) - #if data.text.match(/^\s*<@#{config[:nick_id]}>\s+(on\s+)?<#(\w+)\|([^>]+)>\s*:?\s*(.*)/im) - if data.text.match(/^\s*<@#{config[:nick_id]}>\s+(on\s+)?((<#\w+\|[^>]+>\s*)+)\s*:?\s*(.*)/im) + #todo: we need to add mixed channels: @smart-bot on private1 #bot1cm <#CXDDFRDDF|bot2cu>: echo A + if data.text.match(/^\s*<@#{config[:nick_id]}>\s+(on\s+)?((<#\w+\|[^>]+>\s*)+)\s*:?\s*(.*)/im) or + data.text.match(/^\s*<@#{config[:nick_id]}>\s+(on\s+)?((#[a-zA-Z0-9]+\s*)+)\s*:?\s*(.*)/im) or + data.text.match(/^\s*<@#{config[:nick_id]}>\s+(on\s+)?(([a-zA-Z0-9]+\s*)+)\s*:\s*(.*)/im) channels_rules = $2 #multiple channels @smart-bot on #channel1 #channel2 echo AAA data_text = $4 channel_rules_name = '' channel_rules = '' + channels_arr = channels_rules.scan(/<#(\w+)\|([^>]+)>/) + if channels_arr.size == 0 + channels_arr = [] + channels_rules.scan(/([^\s]+)/).each do |cn| + cna = cn.join.gsub('#','') + channels_arr << [@channels_id[cna], cna] + end + end # to be treated only on the bots of the requested channels - channels_rules.scan(/<#(\w+)\|([^>]+)>/).each do |tcid, tcname| + channels_arr.each do |tcid, tcname| if @channel_id == tcid data.text = data_text typem = :on_call channel_rules = tcid channel_rules_name = tcname @@ -232,10 +242,11 @@ file_cts = IO.readlines("#{config.path}/config_tmp.status").join unless file_cts.to_s() == "" file_cts = eval(file_cts) if file_cts.is_a?(Hash) and file_cts.key?(:on_maintenance) config.on_maintenance = file_cts.on_maintenance + config.on_maintenance_message = file_cts.on_maintenance_message end end end when /From now on I won't be on maintenance/i sleep 2 @@ -243,9 +254,10 @@ file_cts = IO.readlines("#{config.path}/config_tmp.status").join unless file_cts.to_s() == "" file_cts = eval(file_cts) if file_cts.is_a?(Hash) and file_cts.key?(:on_maintenance) config.on_maintenance = file_cts.on_maintenance + config.on_maintenance_message = file_cts.on_maintenance_message end end end when /^Bot has been (closed|killed) by/i