Replies: 1 comment
-
Also, it is recommended that connect_channel be separated into a separate function, since this would make it necessary to follow the channel when it is changed. async def reconnect(ws):
await Router(ws).connect_channel(["global", "main"])
class MyBot(commands.Bot):
def __init__(self):
super().__init__()
async def on_ready(self, ws):
await reconnect(ws)
async def on_reconnect(self, ws):
await reconnect(ws)
async def on_message(self, note: Note):
print(note.author.username, note.content) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
A quick example of use is
Because the websocket connection may be lost due to network issues, reconnecting will disconnect all linked channels and result in no messages being received.
So, to reconnect to the right channels, you must listen for the reconnect event, as shown below.
Enjoy your use!
Beta Was this translation helpful? Give feedback.
All reactions