lib/slack/smart-bot/process_first.rb in slack-smart-bot-1.5.1 vs lib/slack/smart-bot/process_first.rb in slack-smart-bot-1.6.0
- old
+ new
@@ -186,12 +186,17 @@
end
command = command2
on_demand = true
end
if @status == :on and
- (@questions.keys.include?(nick) or
- (@listening.include?(nick) and typem != :on_extended) or
+ (@questions.key?(nick) or
+ (@repl_sessions.key?(nick) and dest==@repl_sessions[nick][:dest] and
+ ((@repl_sessions[nick][:on_thread] and thread_ts == @repl_sessions[nick][:thread_ts]) or
+ (!@repl_sessions[nick][:on_thread] and !Thread.current[:on_thread] ))) or
+ (@listening.key?(nick) and typem != :on_extended and
+ ((@listening[nick].key?(dest) and !Thread.current[:on_thread]) or
+ (@listening[nick].key?(thread_ts) and Thread.current[:on_thread] ) )) or
dest[0] == "D" or on_demand)
@logger.info "command: #{nick}> #{command}" unless processed
#todo: verify this
if dest[0] == "C" or dest[0] == "G" or (dest[0] == "D" and typem == :on_call)
@@ -226,11 +231,11 @@
end
elsif @rules_imported.key?(user.id) and @rules_imported[user.id].key?(user.id)
if @bots_created.key?(@rules_imported[user.id][user.id])
if @bots_created[@rules_imported[user.id][user.id]][:status] == :on
begin
- eval(File.new(config.path+rules_file).read) if File.exist?(config.path+rules_file)
+ eval(File.new(config.path+rules_file).read) if File.exist?(config.path+rules_file) and !['.','..'].include?(config.path + rules_file)
rescue Exception => stack
@logger.fatal "ERROR ON imported RULES FILE: #{rules_file}"
@logger.fatal stack
end
else
@@ -261,9 +266,18 @@
end
unless processed
dont_understand('')
end
end
+
+ if processed and @listening.key?(nick)
+ if Thread.current[:on_thread] and @listening[nick].key?(Thread.current[:thread_ts])
+ @listening[nick][Thread.current[:thread_ts]] = Time.now
+ elsif !Thread.current[:on_thread] and @listening[nick].key?(dest)
+ @listening[nick][dest] = Time.now
+ end
+ end
+
end
rescue Exception => stack
@logger.fatal stack
end
end