Skip to content

Commit

Permalink
Leave current connected channel when joining a second channel
Browse files Browse the repository at this point in the history
  • Loading branch information
douglascdev committed Oct 12, 2023
1 parent 77a109c commit 7dc1016
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Changes:
* Fix UI update error
* Leave current connected channel when joining a second channel
4 changes: 4 additions & 0 deletions hasherino/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,10 @@ async def join_chat_click(_):
websocket: TwitchWebsocket = await self.storage.get("websocket")
self.page.dialog.open = False
await self.page.update_async()

if await self.storage.get("channel"):
await websocket.leave_channel(await self.storage.get("channel"))

await websocket.join_channel(channel.value)
await self.storage.set("channel", channel.value)
await self.page.update_async()
Expand Down
6 changes: 6 additions & 0 deletions hasherino/twitch_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,12 @@ async def join_channel(self, channel: str):

await self._websocket.send(f"JOIN #{channel}")

async def leave_channel(self, channel: str):
if self._websocket is None:
raise Exception("Websocket not connected")

await self._websocket.send(f"PART #{channel}")

async def send_message(self, channel: str, message: str):
logging.debug(f"Sending message on channel {channel} message: {message}")

Expand Down

0 comments on commit 7dc1016

Please sign in to comment.