Skip to content

Commit 55c5eb4

Browse files
authored
Chatter cache fix and typo corrections (#208)
* Replace if statement with if expression * Simplify conditional into return statement * Inline variable that is immediately returned * Comparison moved to the right Use set when checking membership of a collection of literals * Inline variable that is immediately returned * remove none from dict.get returns none by default * Replace if statement with if expression Replace multiple comparisons of same variable with `in` operator Remove redundant conditional * Merge nested if conditions Remove none from dict.get returns none by default * Lift code into else after jump in control flow, Merge else clause's nested if statement into elif Remove redundant pass statements Simplify logical expression * Inline variable that is immediately returned * Merge nested if conditions Inline variable that is immediately returned * Merge nested if conditions * Swap if/else branches, Remove unnecessary else after guard condition * Replace unneeded comprehension with generator * added fetch_channel to client * formatting * remove typehint of User * Added fetch_follow method Removed for loop for fetch_channel * Update README.rst Added myself....just because * fix remove_cog * Fixed remove_cog * changed from list to set * Moved fetch_follow to user from client Fixed black formatting to 120 * Added ChannelInfo class in models Changed fetch_channel to return the ChannelInfo object * Removed except from remove_cog Issue was in unload_module Missing .items() for callsbacks Missing .__name__ for comparison * fixed reload_module * added created_at to User class * Routine fix where after task run completion iterations would set to 0 and run infinitely. * Add typehint for PartialUser in fetch_follow * Removed duplicate fetch_channel Updated docstring fetch_channel * Changed badges to a property returns a dict * change to more obvious wording * fetch duplicate fetch_channel update docstring * added founder to is_subscriber * Update websocket to fix chatters Correct some typos Update badges docstring Fix eventsub BanData key * reverted changes to ChannelBanData model * changed payload key to is_permanent for ChannelBanData
1 parent 8b555f5 commit 55c5eb4

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

twitchio/chatter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def name(self) -> str:
143143

144144
@property
145145
def badges(self) -> dict:
146-
"""The users name. This may be formatted differently than display name."""
146+
"""The users badges."""
147147
return {k: v for k, v in [badge.split("/") for badge in self._badges.split(",")]}
148148

149149
@property

twitchio/ext/eventsub/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def __init__(self, client: "EventSubClient", data: dict):
143143
self.moderator = _transform_user(client, data, "moderator_user")
144144
self.reason: str = data["reason"]
145145
self.ends_at: Optional[datetime.datetime] = data["ends_at"] and _parse_datetime(data["ends_at"])
146-
self.permenant: bool = data["permenant"]
146+
self.permenant: bool = data["is_permanent"]
147147

148148

149149
class ChannelSubscribeData(EventData):
@@ -350,7 +350,7 @@ class _SubscriptionTypes(metaclass=_SubTypesMeta):
350350
subscription = "channel.subscribe", 1, ChannelSubscribeData
351351
cheer = "channel.cheer", 1, ChannelCheerData
352352
raid = "channel.raid", 1, ChannelRaidData
353-
ban = "chnnel.ban", 1, ChannelBanData
353+
ban = "channel.ban", 1, ChannelBanData
354354
unban = "channel.unban", 1, ChannelUnbanData
355355

356356
channel_update = "channel.update", 1, ChannelUpdateData

twitchio/http.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,9 @@ async def _request(self, route, path, headers, utilize_bucket=True):
208208

209209
async with self.session.request(route.method, path, headers=headers, data=route.body) as resp:
210210
try:
211-
logger.debug(f"Recived a response from a request with status {resp.status}: {await resp.json()}")
211+
logger.debug(f"Received a response from a request with status {resp.status}: {await resp.json()}")
212212
except Exception:
213-
logger.debug(f"Recived a response from a request with status {resp.status} and without body")
213+
logger.debug(f"Received a response from a request with status {resp.status} and without body")
214214

215215
if 500 <= resp.status <= 504:
216216
reason = resp.reason

twitchio/websocket.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,8 @@ async def _userstate(self, parsed): # TODO
385385
self._cache_add(parsed)
386386

387387
channel = Channel(name=parsed["channel"], websocket=self)
388-
user = Chatter(tags=parsed["badges"], name=parsed["nick"], channel=channel, bot=self._client, websocket=self)
388+
name = parsed["user"] or parsed["nick"]
389+
user = Chatter(tags=parsed["badges"], name=name, channel=channel, bot=self._client, websocket=self)
389390

390391
self.dispatch("userstate", user)
391392

@@ -425,8 +426,9 @@ def _cache_add(self, parsed: dict):
425426
user = PartialChatter(name=u, bot=self._client, websocket=self, channel=channel_)
426427
self._cache[channel].add(user)
427428
else:
429+
name = parsed["user"] or parsed["nick"]
428430
user = Chatter(
429-
bot=self._client, name=parsed["nick"], websocket=self, channel=channel_, tags=parsed["badges"]
431+
bot=self._client, name=name, websocket=self, channel=channel_, tags=parsed["badges"]
430432
)
431433
self._cache[channel].discard(user)
432434
self._cache[channel].add(user)

0 commit comments

Comments
 (0)