Skip to content

Commit 239a4ae

Browse files
Fix #209 (#322)
* Fix #209 * Added changelog and docs Co-authored-by: Tom <[email protected]>
1 parent 9a61aac commit 239a4ae

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

docs/changelog.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@ Master
44
======
55
- TwitchIO
66
- Additions
7+
- Added :func:`~twitchio.Client.event_channel_join_failure` event:
8+
- This is dispatched when the bot fails to join a channel
9+
- This also makes the channel join error message in logs optional
10+
- Bug fixes
11+
- Fix channel join failures causing `ValueError: list.remove(x): x not in list` when joining channels after the initial start
712
- Added :attr:`~twitchio.Chatter.is_vip` property to Chatter
813
- New PartialUser methods
914
- :func:`~twitchio.PartialUser.fetch_follower_count` to fetch total follower count of a User
1015
- :func:`~twitchio.PartialUser.fetch_following_count` to fetch total following count of a User
1116

12-
- Bug fixes
1317
- Fix whispers that were not able to be parsed
1418
- Fix USERSTATE parsing incorrect user
1519

docs/twitchio.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ Client
1818
:members:
1919
:exclude-members: event_ready, event_raw_data, event_message,
2020
event_join, event_part, event_mode, event_userstate,
21-
event_raw_usernotice, event_usernotice_subscription, event_error
21+
event_raw_usernotice, event_usernotice_subscription, event_error,
22+
event_channel_join_failure
2223

2324
Event Reference
2425
-----------------
@@ -34,6 +35,7 @@ Event Reference
3435
.. automethod:: Client.event_raw_usernotice(channel: Channel, tags: dict)
3536
.. automethod:: Client.event_usernotice_subscription(metadata)
3637
.. automethod:: Client.event_error(error: Exception, data: Optional[str] = None)
38+
.. automethod:: Client.event_channel_join_failure(channel: str)
3739

3840
Exceptions
3941
------------

twitchio/client.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,3 +1007,16 @@ async def event_channel_joined(self, channel: Channel):
10071007
channel: :class:`.Channel`
10081008
The channel that was joined.
10091009
"""
1010+
pass
1011+
1012+
async def event_channel_join_failure(self, channel: str):
1013+
"""|coro|
1014+
1015+
Event called when the bot fails to join a channel.
1016+
1017+
Parameters
1018+
----------
1019+
channel: `str`
1020+
The channel name that was attempted to be joined.
1021+
"""
1022+
logger.error(f'The channel "{channel}" was unable to be joined. Check the channel is valid.')

twitchio/websocket.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ async def _join_future_handle(self, fut: asyncio.Future, channel: str, timeout:
294294
try:
295295
await asyncio.wait_for(fut, timeout=timeout)
296296
except asyncio.TimeoutError:
297-
log.error(f'The channel "{channel}" was unable to be joined. Check the channel is valid.')
297+
self.dispatch("channel_join_failure", channel)
298298
self._join_pending.pop(channel)
299299

300300
data = (
@@ -343,7 +343,7 @@ async def _code(self, parsed, code: int):
343343
self.dispatch("ready")
344344
self._init = True
345345
elif code == 353:
346-
if parsed["channel"] == "TWITCHIOFAILURE":
346+
if parsed["channel"] == "TWITCHIOFAILURE" and parsed["batches"][0] in self._initial_channels:
347347
self._initial_channels.remove(parsed["batches"][0])
348348
if parsed["channel"] in [c.lower().lstrip("#") for c in self._initial_channels] and not self._init:
349349
self._join_load[parsed["channel"]] = None

0 commit comments

Comments
 (0)