Skip to content

Commit

Permalink
Merge pull request #125 from merefield/thread_support
Browse files Browse the repository at this point in the history
FEATURE: add Chat thread support
  • Loading branch information
merefield authored Oct 29, 2024
2 parents 04c1a32 + ab119ca commit 02a0a9a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions lib/discourse_chatbot/message/message_evaluation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/discourse_chatbot/message/message_prompt_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
12 changes: 8 additions & 4 deletions lib/discourse_chatbot/message/message_reply_creator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/discourse_chatbot/reply_creator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion plugin.rb
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit 02a0a9a

Please sign in to comment.