24 lines
798 B
Python
24 lines
798 B
Python
from .utils import get_or_create as goc
|
|
import .models
|
|
from .chatlib import Listener as _l, Event as _e
|
|
|
|
# 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
|
|
room.name=
|
|
room=_l('room','m.room',room_f) |