Sha256: 39e662e87d6d4a1381187d4301e1c53cf25c768074209ffa8d0d9a4fbd45516b
Contents?: true
Size: 1.45 KB
Versions: 4
Compression:
Stored size: 1.45 KB
Contents
class SlackSmartBot #context: previous message #to: user that should answer def ask(question, context = nil, to = nil, dest = nil) if dest.nil? and Thread.current.key?(:dest) dest = Thread.current[:dest] end if to.nil? to = Thread.current[:user].name end if context.nil? context = Thread.current[:command] end message = "#{to}: #{question}" if dest.nil? if config[:simulate] open("#{config.path}/buffer_complete.log", "a") { |f| f.puts "|#{@channel_id}|#{config[:nick_id]}|#{message}~~~" } else client.message(channel: @channel_id, text: message, as_user: true) end if config[:testing] and config.on_master_bot open("#{config.path}/buffer.log", "a") { |f| f.puts "|#{@channel_id}|#{config[:nick_id]}|#{message}" } end elsif dest[0] == "C" or dest[0] == "G" # channel if config[:simulate] open("#{config.path}/buffer_complete.log", "a") { |f| f.puts "|#{dest}|#{config[:nick_id]}|#{message}~~~" } else client.message(channel: dest, text: message, as_user: true) end if config[:testing] and config.on_master_bot open("#{config.path}/buffer.log", "a") { |f| f.puts "|#{dest}|#{config[:nick_id]}|#{message}" } end elsif dest[0] == "D" #private message send_msg_user(dest, message) end @questions[to] = context end end
Version data entries
4 entries across 4 versions & 1 rubygems