def connect(host, user_id, password): global client try: client = MatrixClient(host, encryption=True, restore_device_id=True) client.login(username=user_id, password=password, sync=False) #client.start_listener_thread(timeout_ms=30000, exception_handler=None) #client.bad_sync_timeout_limit = 0 #client.start_listener_thread() #client.should_listen=30000 client.add_key_forward_listener( lambda x: writetolog('got new keys' + x)) except: logging.exception('') quit() return (client)
assert client.device_id == device_id room = client.join_room(room_id) room.send_text("My device ID is still {}!".format(device_id)) ## Advanced usage # Device verification room.verify_devices = True try: room.send_text("Do I know everyone?") except E2EUnknownDevices as e: # We don't know anyone, but send anyway for user_id, devices in e.user_devices.items(): for device in devices: device.ignored = True # Out-of-band verification should allow to do device.verified = True instead room.send_text("Now I know everyone, kind of.") # Key sharing # Print every keys which arrive to us client.add_key_forward_listener(lambda x: print(x)) # Share keys everytime we receive a request from another of our devices (do not do this) client.add_key_request_listener(lambda x, f: f(x))