Sha256: cacfc5f876e6918b02a95c119b664b11e493a48a6efe2842a9e84e00b23fbc74

Contents?: true

Size: 1.09 KB

Versions: 15

Compression:

Stored size: 1.09 KB

Contents

class SlackSmartBot

  # to: (String) Channel name or id
  # msg: (String) message to send
  def send_msg_channel(to, msg)
    unless msg == ""
      get_channels_name_and_id() unless @channels_name.key?(to) or @channels_id.key?(to)
      if @channels_name.key?(to) #it is an id
        channel_id = to
      elsif @channels_id.key?(to) #it is a channel name
        channel_id = @channels_id[to]
      else
        @logger.fatal "Channel: #{to} not found. Message: #{msg}"
      end
      if config[:simulate]
        open("#{config.path}/buffer_complete.log", "a") { |f|
          f.puts "|#{channel_id}|#{config[:nick_id]}|#{msg}~~~"
        }
      else  
        if Thread.current[:on_thread]
          client.message(channel: channel_id, text: msg, as_user: true, thread_ts: Thread.current[:thread_ts])
        else
          client.message(channel: channel_id, text: msg, as_user: true)
        end
      end
      if config[:testing] and config.on_master_bot
        open("#{config.path}/buffer.log", "a") { |f|
          f.puts "|#{channel_id}|#{config[:nick_id]}|#{msg}"
        }
      end
    end
  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
slack-smart-bot-1.8.2 lib/slack/smart-bot/comm/send_msg_channel.rb
slack-smart-bot-1.8.1 lib/slack/smart-bot/comm/send_msg_channel.rb
slack-smart-bot-1.8.0 lib/slack/smart-bot/comm/send_msg_channel.rb
slack-smart-bot-1.7.0 lib/slack/smart-bot/comm/send_msg_channel.rb
slack-smart-bot-1.6.8 lib/slack/smart-bot/comm/send_msg_channel.rb
slack-smart-bot-1.6.7 lib/slack/smart-bot/comm/send_msg_channel.rb
slack-smart-bot-1.6.6 lib/slack/smart-bot/comm/send_msg_channel.rb
slack-smart-bot-1.6.5 lib/slack/smart-bot/comm/send_msg_channel.rb
slack-smart-bot-1.6.4 lib/slack/smart-bot/comm/send_msg_channel.rb
slack-smart-bot-1.6.3 lib/slack/smart-bot/comm/send_msg_channel.rb
slack-smart-bot-1.6.2 lib/slack/smart-bot/comm/send_msg_channel.rb
slack-smart-bot-1.6.1 lib/slack/smart-bot/comm/send_msg_channel.rb
slack-smart-bot-1.6.0 lib/slack/smart-bot/comm/send_msg_channel.rb
slack-smart-bot-1.5.1 lib/slack/smart-bot/comm/send_msg_channel.rb
slack-smart-bot-1.5.0 lib/slack/smart-bot/comm/send_msg_channel.rb