Add on_connected to client
This commit is contained in:
parent
f46ca47a28
commit
f40fb2d45d
3 changed files with 12 additions and 1 deletions
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
## Next version
|
## Next version
|
||||||
|
|
||||||
- add ALIASES variable to Bot
|
- add `ALIASES` variable to `Bot`
|
||||||
|
- add `on_connected` function to `Client`
|
||||||
|
|
||||||
## 0.1.0 (2019-04-12)
|
## 0.1.0 (2019-04-12)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,8 @@ class Client:
|
||||||
nick = self._default_nick
|
nick = self._default_nick
|
||||||
room = Room(room_name, password=password, target_nick=nick)
|
room = Room(room_name, password=password, target_nick=nick)
|
||||||
|
|
||||||
|
room.register_event("connected",
|
||||||
|
functools.partial(self.on_connected, room))
|
||||||
room.register_event("snapshot",
|
room.register_event("snapshot",
|
||||||
functools.partial(self.on_snapshot, room))
|
functools.partial(self.on_snapshot, room))
|
||||||
room.register_event("send",
|
room.register_event("send",
|
||||||
|
|
@ -102,6 +104,9 @@ class Client:
|
||||||
|
|
||||||
# Event stuff - overwrite these functions
|
# Event stuff - overwrite these functions
|
||||||
|
|
||||||
|
async def on_connected(self, room: Room) -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
async def on_snapshot(self, room: Room, messages: List[LiveMessage]) -> None:
|
async def on_snapshot(self, room: Room, messages: List[LiveMessage]) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,10 @@ class Room:
|
||||||
"""
|
"""
|
||||||
Events and parameters:
|
Events and parameters:
|
||||||
|
|
||||||
|
"connected" - fired after the Room has authenticated, joined and set its
|
||||||
|
nick, meaning that now, messages can be sent
|
||||||
|
no parameters
|
||||||
|
|
||||||
"snapshot" - snapshot of the room's messages at the time of joining
|
"snapshot" - snapshot of the room's messages at the time of joining
|
||||||
messages: List[LiveMessage]
|
messages: List[LiveMessage]
|
||||||
|
|
||||||
|
|
@ -207,6 +211,7 @@ class Room:
|
||||||
if self._target_nick and nick_needs_updating:
|
if self._target_nick and nick_needs_updating:
|
||||||
await self._nick(self._target_nick)
|
await self._nick(self._target_nick)
|
||||||
|
|
||||||
|
self._events.fire("connected")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
async def disconnect(self) -> None:
|
async def disconnect(self) -> None:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue