Skip to content

Commit d28d915

Browse files
committed
Added the last missing action
1 parent f0296a3 commit d28d915

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

backend/PyMatcha/utils/bot_actions.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
from PyMatcha.utils.static import BACKEND_ROOT
1414
from PyMatcha.utils.static import BOT_CONV_OPENERS
1515

16-
# TODO: send a new message in already started conversation
17-
1816

1917
def _bot_response(bot_name, user_input):
2018
logging.debug(f"Starting chatbot with name {bot_name}")
@@ -111,3 +109,18 @@ def botaction_respond_to_unread(bot_user: User):
111109
return
112110
bot_reply = _bot_response(bot_user.username, message_to_reply.content)
113111
bot_user.send_message(to_id=message_to_reply.from_id, content=bot_reply)
112+
113+
114+
def botaction_send_message_over_old_one(bot_user: User):
115+
last_message_list = bot_user.get_conversation_list()
116+
try:
117+
message_to_reply = choice(last_message_list)
118+
except IndexError:
119+
return
120+
if message_to_reply.to_id == bot_user.id:
121+
other_user = message_to_reply.from_id
122+
else:
123+
other_user = message_to_reply.to_id
124+
125+
bot_reply = _bot_response(bot_user.username, ".")
126+
bot_user.send_message(to_id=other_user, content=bot_reply)

0 commit comments

Comments
 (0)