Skip to content

Commit f111e67

Browse files
committed
Fix event loop issues
Fix errors when event loop is started using run_until_complete to call methods prior to Client.run
1 parent 239a4ae commit f111e67

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Master
1616

1717
- Fix whispers that were not able to be parsed
1818
- Fix USERSTATE parsing incorrect user
19+
- Fix errors when event loop is started using `run_until_complete` to call methods prior to :func:`~twitchio.Client.run`
1920

2021
- ext.commands
2122
- Bug fixes

twitchio/parse.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,6 @@ def parser(data: str, nick: str):
8383
if action == "WHISPER":
8484
channel = None
8585

86-
if action == "USERSTATE":
87-
user = None
88-
8986
if action in ACTIONS2:
9087
prebadge = groups[0].split(";")
9188
badges = {}
@@ -98,6 +95,12 @@ def parser(data: str, nick: str):
9895
except IndexError:
9996
pass
10097

98+
if action == "USERSTATE" and badges.get("display-name"):
99+
user = badges.get("display-name").lower()
100+
101+
if action == "USERNOTICE" and badges.get("login"):
102+
user = badges.get("login").lower()
103+
101104
if action not in ACTIONS and action not in ACTIONS2:
102105
action = None
103106

@@ -120,6 +123,8 @@ def parser(data: str, nick: str):
120123
else:
121124
logger.warning(f" (353) parse failed? ||{channel}||")
122125

126+
if user is None:
127+
user = groups[-1][1:].lower()
123128
for b in groups[5:-1]:
124129
if b[0] == ":":
125130
b = b[1:]

twitchio/websocket.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ async def _connect(self):
125125
data = await self._client._http.validate(token=self._token)
126126
self.nick = data["login"]
127127
self.user_id = int(data["user_id"])
128+
else:
129+
self.nick = self._client._http.nick
128130
session = self._client._http.session
129131

130132
try:

0 commit comments

Comments
 (0)