File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 1313from PyMatcha .utils .static import BACKEND_ROOT
1414from PyMatcha .utils .static import BOT_CONV_OPENERS
1515
16- # TODO: send a new message in already started conversation
17-
1816
1917def _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 )
You can’t perform that action at this time.
0 commit comments