catch error
This commit is contained in:
parent
93e2f34952
commit
7bfc02ebbd
|
@ -7,7 +7,7 @@ from typing import List, Optional, Union
|
|||
|
||||
import stopit
|
||||
from markdown import markdown
|
||||
from nio import (AsyncClient, ErrorResponse, Event, MatrixRoom, MegolmEvent, Response, RoomMessageText, RoomSendResponse, SendRetryError, )
|
||||
from nio import (AsyncClient, ErrorResponse, Event, MatrixRoom, MegolmEvent, Response, RoomGetEventResponse, RoomMessageText, RoomSendResponse, SendRetryError, )
|
||||
|
||||
logger = logging.getLogger('MatrixGPT')
|
||||
|
||||
|
@ -114,9 +114,13 @@ def is_thread(event: RoomMessageText):
|
|||
|
||||
async def is_this_our_thread(client: AsyncClient, room: MatrixRoom, event: RoomMessageText, command_flag: str):
|
||||
base_event_id = event.source['content'].get('m.relates_to', {}).get('event_id')
|
||||
logger.debug((await client.room_get_event(room.room_id, base_event_id)).event.body)
|
||||
if base_event_id:
|
||||
return (await client.room_get_event(room.room_id, base_event_id)).event.body.startswith(f'{command_flag} ')
|
||||
e = await client.room_get_event(room.room_id, base_event_id)
|
||||
if not isinstance(e, RoomGetEventResponse):
|
||||
logger.critical(f'Failed to get event in is_this_our_thread(): {vars(e)}')
|
||||
return
|
||||
else:
|
||||
return e.event.body.startswith(f'{command_flag} ')
|
||||
else:
|
||||
return False
|
||||
|
||||
|
|
Loading…
Reference in New Issue