Sha256: a39173310220fb1d69417470869e95209bca6622bc95de9b8b583969d83c4586

Contents?: true

Size: 1.54 KB

Versions: 15

Compression:

Stored size: 1.54 KB

Contents

class SlackSmartBot

  #to send messages without listening for a response to users
  def send_msg_user(id_user, msg)
    unless msg == ""
      if id_user[0] == "D"
        if config[:simulate]
          open("#{config.path}/buffer_complete.log", "a") { |f|
            f.puts "|#{id_user}|#{config[:nick_id]}|#{msg}~~~"
          }
        else  
          if Thread.current[:on_thread]
            client.message(channel: id_user, as_user: true, text: msg, thread_ts: Thread.current[:thread_ts])
          else
            client.message(channel: id_user, as_user: true, text: msg)
          end
        end
        if config[:testing] and config.on_master_bot
          open("#{config.path}/buffer.log", "a") { |f|
            f.puts "|#{id_user}|#{config[:nick_id]}|#{msg}"
          }
        end
      else
        im = client.web_client.im_open(user: id_user)
        if config[:simulate]
          open("#{config.path}/buffer_complete.log", "a") { |f|
            f.puts "|#{im["channel"]["id"]}|#{config[:nick_id]}|#{msg}~~~"
          }
        else  
          if Thread.current[:on_thread]
            client.message(channel: im["channel"]["id"], as_user: true, text: msg, thread_ts: Thread.current[:thread_ts])
          else
            client.message(channel: im["channel"]["id"], as_user: true, text: msg)
          end
        end
        if config[:testing] and config.on_master_bot
          open("#{config.path}/buffer.log", "a") { |f|
            f.puts "|#{im["channel"]["id"]}|#{config[:nick_id]}|#{msg}"
          }
        end
      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_user.rb
slack-smart-bot-1.8.1 lib/slack/smart-bot/comm/send_msg_user.rb
slack-smart-bot-1.8.0 lib/slack/smart-bot/comm/send_msg_user.rb
slack-smart-bot-1.7.0 lib/slack/smart-bot/comm/send_msg_user.rb
slack-smart-bot-1.6.8 lib/slack/smart-bot/comm/send_msg_user.rb
slack-smart-bot-1.6.7 lib/slack/smart-bot/comm/send_msg_user.rb
slack-smart-bot-1.6.6 lib/slack/smart-bot/comm/send_msg_user.rb
slack-smart-bot-1.6.5 lib/slack/smart-bot/comm/send_msg_user.rb
slack-smart-bot-1.6.4 lib/slack/smart-bot/comm/send_msg_user.rb
slack-smart-bot-1.6.3 lib/slack/smart-bot/comm/send_msg_user.rb
slack-smart-bot-1.6.2 lib/slack/smart-bot/comm/send_msg_user.rb
slack-smart-bot-1.6.1 lib/slack/smart-bot/comm/send_msg_user.rb
slack-smart-bot-1.6.0 lib/slack/smart-bot/comm/send_msg_user.rb
slack-smart-bot-1.5.1 lib/slack/smart-bot/comm/send_msg_user.rb
slack-smart-bot-1.5.0 lib/slack/smart-bot/comm/send_msg_user.rb