Teekeks / pyTwitchAPI

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

pyTwitchAPI should provide methods for connection status #186

Closed aw-was-here closed 1 year ago

aw-was-here commented 1 year ago

With regards to #185 , it becomes evident that clients of pyTwitchAPI should have the ability to know whether any given socket connection is alive or dead. It would be useful to expose something like is_ready() or is_connected() method to know whether the given connection is actually functioning. This method could be used prior to using that particular subsystem for proactive error handling rather than waiting for any sort of exception being raised.

e.g.:

if not chat.is_connected():
    pop_up_error_window()
    restart_chat()
chat.send_mesage('still here')
Teekeks commented 1 year ago

Added in 4db8362a1f18881f5bee4dc1a7f4d4ba192237ea