warn about encryption failure
This commit is contained in:
parent
4271e2668f
commit
7dc2bf12b6
|
@ -5,7 +5,7 @@ import time
|
||||||
from nio import (AsyncClient, InviteMemberEvent, JoinError, MatrixRoom, MegolmEvent, RoomMessageText, UnknownEvent, )
|
from nio import (AsyncClient, InviteMemberEvent, JoinError, MatrixRoom, MegolmEvent, RoomMessageText, UnknownEvent, )
|
||||||
|
|
||||||
from .bot_commands import Command
|
from .bot_commands import Command
|
||||||
from .chat_functions import check_authorized, get_thread_content, is_thread, process_chat, react_to_event
|
from .chat_functions import check_authorized, get_thread_content, is_thread, process_chat, react_to_event, send_text_to_room
|
||||||
# from .config import Config
|
# from .config import Config
|
||||||
from .storage import Storage
|
from .storage import Storage
|
||||||
|
|
||||||
|
@ -75,13 +75,18 @@ class Callbacks:
|
||||||
thread_content = await get_thread_content(self.client, room, event)
|
thread_content = await get_thread_content(self.client, room, event)
|
||||||
api_data = []
|
api_data = []
|
||||||
for event in thread_content:
|
for event in thread_content:
|
||||||
api_data.append({'role': 'assistant' if event.sender == self.client.user_id else 'user', 'content': event.body if not event.body.startswith(self.command_prefix) else event.body[
|
if isinstance(event, MegolmEvent):
|
||||||
len(self.command_prefix):].strip()}) # if len(thread_content) >= 2 and thread_content[0].body.startswith(self.command_prefix): # if thread_content[len(thread_content) - 2].sender == self.client.user
|
await send_text_to_room(self.client, room.room_id, 'Decryption Failure', reply_to_event_id=event.event_id, thread=True, thread_root_id=thread_content[0].event_id)
|
||||||
|
else:
|
||||||
|
api_data.append({
|
||||||
|
'role': 'assistant' if event.sender == self.client.user_id else 'user',
|
||||||
|
'content': event.body if not event.body.startswith(self.command_prefix) else event.body[len(self.command_prefix):].strip()
|
||||||
|
}) # if len(thread_content) >= 2 and thread_content[0].body.startswith(self.command_prefix): # if thread_content[len(thread_content) - 2].sender == self.client.user
|
||||||
|
|
||||||
# message = Message(self.client, self.store, msg, room, event, self.reply_in_thread)
|
# message = Message(self.client, self.store, msg, room, event, self.reply_in_thread)
|
||||||
# await message.process()
|
# await message.process()
|
||||||
api_data.append({'role': 'user', 'content': event.body})
|
api_data.append({'role': 'user', 'content': event.body})
|
||||||
await process_chat(self.client, room, event, api_data, self.store, self.openai, thread_root_id=thread_content[0].event_id, system_prompt=self.system_prompt)
|
await process_chat(self.client, room, event, api_data, self.store, self.openai, thread_root_id=thread_content[0].event_id, system_prompt=self.system_prompt)
|
||||||
return
|
return
|
||||||
elif msg.startswith(f'{self.command_prefix} ') or room.member_count == 2:
|
elif msg.startswith(f'{self.command_prefix} ') or room.member_count == 2:
|
||||||
# Otherwise if this is in a 1-1 with the bot or features a command prefix, treat it as a command.
|
# Otherwise if this is in a 1-1 with the bot or features a command prefix, treat it as a command.
|
||||||
|
|
Loading…
Reference in New Issue