diff --git a/lib/discourse_chatbot/message/message_evaluation.rb b/lib/discourse_chatbot/message/message_evaluation.rb index 360b919..2271adf 100644 --- a/lib/discourse_chatbot/message/message_evaluation.rb +++ b/lib/discourse_chatbot/message/message_evaluation.rb @@ -57,6 +57,7 @@ def on_submission(submission) bot_user_id: bot_user_id, reply_to_message_or_post_id: chat_message.id, topic_or_channel_id: channel_id, + thread_id: chat_message.thread_id, over_quota: over_quota, trust_level: trust_level(user.id), human_participants_count: bot_chat_channel ? message_channel_user_count - 1 : message_channel_user_count, diff --git a/lib/discourse_chatbot/message/message_prompt_utils.rb b/lib/discourse_chatbot/message/message_prompt_utils.rb index b4968b3..3581975 100644 --- a/lib/discourse_chatbot/message/message_prompt_utils.rb +++ b/lib/discourse_chatbot/message/message_prompt_utils.rb @@ -58,7 +58,7 @@ def self.collect_past_interactions(message_or_post_id) else prior_message = ::Chat::Message - .where(chat_channel_id: current_message.chat_channel_id, deleted_at: nil) + .where(chat_channel_id: current_message.chat_channel_id, thread_id: current_message.thread_id, deleted_at: nil) .where("chat_messages.id < ?", current_message.id) .last if prior_message.nil? diff --git a/lib/discourse_chatbot/message/message_reply_creator.rb b/lib/discourse_chatbot/message/message_reply_creator.rb index f8fc4c7..31bd777 100644 --- a/lib/discourse_chatbot/message/message_reply_creator.rb +++ b/lib/discourse_chatbot/message/message_reply_creator.rb @@ -20,11 +20,15 @@ def create end end + params = { + chat_channel_id: @topic_or_channel_id, + message: @message_body + } + + params.merge!(thread_id: @thread_id) if @thread_id.present? + Chat::CreateMessage.call( - params: { - chat_channel_id: @topic_or_channel_id, - message: @message_body - }, + params: params, guardian: @guardian ) begin diff --git a/lib/discourse_chatbot/reply_creator.rb b/lib/discourse_chatbot/reply_creator.rb index 59e6f5d..4c15589 100644 --- a/lib/discourse_chatbot/reply_creator.rb +++ b/lib/discourse_chatbot/reply_creator.rb @@ -9,6 +9,7 @@ def initialize(options = {}) @reply_to = options[:reply_to_message_or_post_id] @reply_to_post_number = options[:original_post_number] @topic_or_channel_id = options[:topic_or_channel_id] + @thread_id = options[:thread_id] @message_body = options[:reply] @is_private_msg = options[:is_private_msg] @private = options[:private] diff --git a/plugin.rb b/plugin.rb index 7208c99..4859ff7 100644 --- a/plugin.rb +++ b/plugin.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # name: discourse-chatbot # about: a plugin that allows you to have a conversation with a configurable chatbot in Discourse Chat, Topics and Private Messages -# version: 1.3.2 +# version: 1.4.0 # authors: merefield # url: https://github.com/merefield/discourse-chatbot