Teekeks / pyTwitchAPI

A Python 3.7 compatible implementation of the Twitch API, EventSub, PubSub and Chat
https://pytwitchapi.dev
MIT License
256 stars 38 forks source link

Twitch Chat Bot: KeyError on a Clear chat event #194

Closed stolenvw closed 1 year ago

stolenvw commented 1 year ago
2023-01-22 16:49:44 - ERROR - asyncio: Task exception was never retrieved
future: <Task finished name='Task-2434' coro=<Chat._handle_clear_chat() done, defined at /home/user/test-twitch-bot/.twitchtestenv/lib/python3.10/site-packages/twitchAPI/chat.py:890> exception=KeyError('ban-duration')>
Traceback (most recent call last):
  File "/home/user/test-twitch-bot/.twitchtestenv/lib/python3.10/site-packages/twitchAPI/chat.py", line 891, in _handle_clear_chat
    e = ClearChatEvent(self, parsed)
  File "/home/user/test-twitch-bot/.twitchtestenv/lib/python3.10/site-packages/twitchAPI/chat.py", line 488, in __init__
    self.duration: Optional[int] = int(parsed['tags']['ban-duration']) if parsed['tags']['ban-duration'] not in (None, '') else None
KeyError: 'ban-duration'

Did not have debug logging on for twitchAPI.chat , happened after a users messages where deleted.

Teekeks commented 1 year ago

Fix is available on pypi, version 3.5.1