Skip to content

Commit

Permalink
Fixed updating channels listing failing if no channels were in data
Browse files Browse the repository at this point in the history
  • Loading branch information
thelabcat committed Jan 19, 2025
1 parent 18d25e7 commit 3408709
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "cocorum"
version = "2.6.0"
version = "2.6.1"
keywords = ["rumble", "api", "wrapper", "livestream"]
authors = [
{ name="Wilbur Jaywright", email="[email protected]" },
Expand Down
6 changes: 3 additions & 3 deletions src/cocorum/chatapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ def update_mailbox(self, jsondata):
"""

#Add new messages
self.__mailbox += [ChatAPIMessage(message_json, self) for message_json in jsondata["data"]["messages"] if int(message_json["id"]) not in self.__mailbox]
self.__mailbox += [ChatAPIMessage(message_json, self) for message_json in jsondata["data"].get("messages", []) if int(message_json["id"]) not in self.__mailbox]

def clear_mailbox(self):
"""Delete anything in the mailbox"""
Expand All @@ -689,7 +689,7 @@ def update_users(self, jsondata):
jsondata (dict): A JSON data block from an SSE event.
"""

for user_json in jsondata["data"]["users"]:
for user_json in jsondata["data"].get("users", []):
try:
self.users[int(user_json["id"])]._jsondata = user_json #Update an existing user's JSON
except KeyError: #User is new
Expand All @@ -702,7 +702,7 @@ def update_channels(self, jsondata):
jsondata (dict): A JSON data block from an SSE event.
"""

for channel_json in jsondata["data"]["channels"]:
for channel_json in jsondata["data"].get("channels", []):
try:
self.channels[int(channel_json["id"])]._jsondata = channel_json #Update an existing channel's JSON
except KeyError: #Channel is new
Expand Down

0 comments on commit 3408709

Please sign in to comment.