Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions matrix_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,18 +352,19 @@ def get_rooms(self):

# TODO: create Listener class and push as much of this logic there as possible
# NOTE: listeners related to things in rooms should be attached to Room objects
def add_listener(self, callback, event_type=None):
def add_listener(self, callback, name=None, event_type=None):
""" Add a listener that will send a callback when the client recieves
an event.

Args:
callback (func(roomchunk)): Callback called when an event arrives.
name (str): Optional listener name to identify the listener more conveniently
event_type (str): The event_type to filter for.

Returns:
uuid.UUID: Unique id of the listener, can be used to identify the listener.
"""
listener_uid = uuid4()
listener_uid = name if name else uuid4()
# TODO: listeners should be stored in dict and accessed/deleted directly. Add
# convenience method such that MatrixClient.listeners.new(Listener(...)) performs
# MatrixClient.listeners[uuid4()] = Listener(...)
Expand Down