Skip to content

Commit e00c403

Browse files
authored
Merge branch 'master' into events
2 parents b46ba8d + ffa8346 commit e00c403

File tree

4 files changed

+23
-13
lines changed

4 files changed

+23
-13
lines changed

docs/changelog.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
:orphan:
1+
:orphan:
22

33

44
Master
@@ -12,6 +12,7 @@ Master
1212
- This is dispatched when the bot fails to join a channel
1313
- This also makes the channel join error message in logs optional
1414
- Bug fixes
15+
- Fix AuthenticationError not being properly propagated when a bad token is given
1516
- Fix channel join failures causing `ValueError: list.remove(x): x not in list` when joining channels after the initial start
1617
- Added :attr:`~twitchio.Chatter.is_vip` property to Chatter
1718
- New PartialUser methods
@@ -37,6 +38,7 @@ Master
3738
- Bug fixes
3839
- Unsubscribing from Pubsubevents works again
3940
- Fix a forgotten nonce in :func:`~twitchio.ext.pubsub.websocket._send_topics`
41+
- :class:`~twitchio.ext.pubsub.PubSubModerationActionChannelTerms` now uses the correct type data
4042

4143
- ext.sound
4244
- Bug fixes
@@ -51,18 +53,17 @@ Master
5153
- :func:`~twitchio.ext.eventsub.event_eventsub_notification_channel_goal_begin`
5254
- :func:`~twitchio.ext.eventsub.event_eventsub_notification_channel_goal_progress`
5355
- :func:`~twitchio.ext.eventsub.event_eventsub_notification_channel_goal_end`
56+
5457
- Channel subscription end
5558
- :func:`~twitchio.ext.eventsub.EventSubClient.subscribe_channel_subscription_end`
5659
- User authorization grant
5760
- :func:`~twitchio.ext.eventsub.EventSubClient.subscribe_user_authorization_granted`
5861

62+
- HypeTrainBeginProgressData now has the :attr:`~twitchio.ext.eventsub.HypeTrainBeginProgressData.level`
63+
64+
5965
- Bug fixes
6066
Correct typo in :class:`~twitchio.ext.eventsub.HypeTrainBeginProgressData` attribute :attr:`~twitchio.ext.eventsub.HypeTrainBeginProgressData.expires`
61-
62-
- ext.pubsub
63-
- Bug fixes
64-
- "type" of :class:`~twitchio.ext.pubsub.PubSubModerationActionChannelTerms` now uses the correct type data
65-
6667

6768
2.4.0
6869
======

twitchio/client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import sys
3131
from typing import Union, Callable, List, Optional, Tuple, Any, Coroutine, Dict
3232

33-
from twitchio.errors import HTTPException
33+
from twitchio.errors import HTTPException, AuthenticationError
3434
from . import models
3535
from .websocket import WSConnection
3636
from .http import TwitchHTTP
@@ -155,7 +155,8 @@ def run(self):
155155
connects to the twitch IRC server, and cleans up when done.
156156
"""
157157
try:
158-
self.loop.create_task(self.connect())
158+
task = self.loop.create_task(self.connect())
159+
self.loop.run_until_complete(task) # this'll raise if the connect fails
159160
self.loop.run_forever()
160161
except KeyboardInterrupt:
161162
pass

twitchio/ext/eventsub/models.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,8 @@ class HypeTrainBeginProgressData(EventData):
682682
The top contributions of the Hype Train
683683
last_contribution: :class:`HypeTrainContributor`
684684
The last contributor to the Hype Train
685+
level: :class:`int`
686+
The current level of the Hype Train
685687
"""
686688

687689
__slots__ = (
@@ -693,6 +695,7 @@ class HypeTrainBeginProgressData(EventData):
693695
"last_contribution",
694696
"started",
695697
"expires",
698+
"level",
696699
)
697700

698701
def __init__(self, client: EventSubClient, data: dict):
@@ -704,6 +707,7 @@ def __init__(self, client: EventSubClient, data: dict):
704707
self.expires = _parse_datetime(data["expires_at"])
705708
self.top_contributions = [HypeTrainContributor(client, d) for d in data["top_contributions"]]
706709
self.last_contribution = HypeTrainContributor(client, data["last_contribution"])
710+
self.level: int = data["level"]
707711

708712

709713
class HypeTrainEndData(EventData):

twitchio/websocket.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,12 @@ async def _connect(self):
122122
if self.is_alive:
123123
await self._websocket.close() # If for some reason we are in a weird state, close it before retrying.
124124
if not self._client._http.nick:
125-
data = await self._client._http.validate(token=self._token)
125+
try:
126+
data = await self._client._http.validate(token=self._token)
127+
except AuthenticationError:
128+
await self._client._http.session.close()
129+
self._client._closing.set() # clean up and error out (this is called to avoid calling Client.close in start()
130+
raise
126131
self.nick = data["login"]
127132
self.user_id = int(data["user_id"])
128133
else:
@@ -137,10 +142,9 @@ async def _connect(self):
137142

138143
await asyncio.sleep(retry)
139144
return asyncio.create_task(self._connect())
140-
if time.time() > self._last_ping + 240 or self._reconnect_requested:
141-
# Re-authenticate as we have surpassed a PING request or Twitch issued a RECONNECT.
142-
await self.authenticate(self._initial_channels)
143-
self._reconnect_requested = False
145+
146+
await self.authenticate(self._initial_channels)
147+
144148
self._keeper = asyncio.create_task(self._keep_alive()) # Create our keep alive.
145149
self._ws_ready_event.set()
146150

0 commit comments

Comments
 (0)