rintrix/listeners.py

24 lines
798 B
Python
Raw Normal View History

from .utils import get_or_create as goc
2022-02-24 16:27:55 +11:00
import .models
from .chatlib import Listener as _l, Event as _e
2022-02-24 16:27:55 +11:00
# Default handlers will be given two parts each:
# 1) Mould the raw event into a parsed event (update internal state)
# 2) Identify event chains and dump them into the queue.
# I really don't recommend removing them. (But I won't stop you.)
def sync_f(client,event):
blob=event.raw_data
# This event never really gets any processed data in it.
rooms=blob['rooms']['join']
for rid,room in rooms.items():
client.event_queue.add(_e('m.room',{'id':rid},room))
sync=_l('sync','m.sync',sync_f)
def room_f(client,event):
blob=event.raw_data
rid=event.data['id']
room=goc(lambda x:x.id==rid,client.account.rooms,models.Room(rid))
event.data=room
2022-08-09 20:36:16 +10:00
room.name=
2022-02-24 16:27:55 +11:00
room=_l('room','m.room',room_f)