set_offline now cancels pending_online task
This commit is contained in:
1 parent
8f8f2609a1
commit
0631a00ff5
1 file changed
+4
-4
+4
-4
@@ -29,11 +29,9 @@ class Stream:
|
|||||||
self.viewer_count = stream["viewersCount"]
|
self.viewer_count = stream["viewersCount"]
|
||||||
self.drops_enabled = any(tag["id"] == DROPS_ENABLED_TAG for tag in stream["tags"])
|
self.drops_enabled = any(tag["id"] == DROPS_ENABLED_TAG for tag in stream["tags"])
|
||||||
settings = data["broadcastSettings"]
|
settings = data["broadcastSettings"]
|
||||||
self.game: Optional[Game]
|
self.game: Optional[Game] = None
|
||||||
if settings["game"] is not None:
|
if settings["game"] is not None:
|
||||||
self.game = Game(settings["game"])
|
self.game = Game(settings["game"])
|
||||||
else:
|
|
||||||
self.game = None
|
|
||||||
self.title = settings["title"]
|
self.title = settings["title"]
|
||||||
self._timestamp = datetime.now(timezone.utc)
|
self._timestamp = datetime.now(timezone.utc)
|
||||||
|
|
||||||
@@ -165,11 +163,13 @@ class Channel:
|
|||||||
|
|
||||||
def set_offline(self):
|
def set_offline(self):
|
||||||
# to be called externally, if we receive an event about this happening
|
# to be called externally, if we receive an event about this happening
|
||||||
|
if self._pending_stream_up is not None:
|
||||||
|
self._pending_stream_up.cancel()
|
||||||
|
self._pending_stream_up = None
|
||||||
self.stream = None
|
self.stream = None
|
||||||
|
|
||||||
def _encode_payload(self):
|
def _encode_payload(self):
|
||||||
assert self.stream is not None
|
assert self.stream is not None
|
||||||
assert self._twitch._user_id is not None
|
|
||||||
payload = [
|
payload = [
|
||||||
{
|
{
|
||||||
"event": "minute-watched",
|
"event": "minute-watched",
|
||||||
|
|||||||
Reference in new issue
Block a user