INNER CODE UNIT · Python
handle_incoming_room_message
zapek/Xeres · scripts/bot/bot.py:211
def handle_incoming_room_message(conn, own_id, destination_id, room_id, sender, gxs_sender, content):
own_nickname = own_id['name'].lower()
# We need to do that because what we say in the room is echoed back, obviously
if gxs_sender == own_id['gxsId']['bytes']:
return
lower_content = content.lower()
if not (lower_content.startswith("@" + own_nickname + " ") or lower_content.startswith(own_nickname + ": ") or lower_content.startswith("@" + own_nickname + ": ")):
return
content = content[(len(own_nickname) + (3 if lower_content.startswith("@" + own_nickname + ": ") else 2)):]
# print(f"Handling message from {sender} in {room_id}: {content}")
content = openai_api_send(content, own_id['name'], sender, gxs_sender, lambda: send_chat_room_typing_notification(conn, own_id, destination_id, room_id))