Skip to content

Commit 8e40fc0

Browse files
committed
Fix PubSubChannelSubscribe model
PartialUser had incorrect args and self.message needs to be a string, not PubSubChatMessage.
1 parent c0ce07e commit 8e40fc0

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

docs/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Massive documentation updates
1111
- :func:`Bot.handle_commands` now also invokes on threads / replies
1212
- Cooldowns are now handled correctly per bucket.
1313

14+
- ext.pubsub
15+
- Channel subscription model fixes.
1416

1517
2.2.0
1618
=====

docs/exts/pubsub.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,6 @@ If the topic requires multiple channel ids, they should be passed as such:
151151
152152
.. function:: channel_subscriptions(oauth_token: str)
153153

154-
.. warning::
155-
156-
This does not have a model created yet, and will error when a subscription event is received
157-
158154
This topic listens for subscriptions on the given channel.
159155
This topic dispatches the ``pubsub_subscription`` client event.
160156
This topic takes one channel id, the channel to listen on, e.g.:

twitchio/ext/pubsub/models.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -399,13 +399,11 @@ def __init__(self, client: Client, topic: str, data: dict):
399399
self.context: str = subscription["context"]
400400

401401
try:
402-
self.user = (
403-
PartialUser(client._http, subscription["user_name"], int(subscription["user_id"])),
404-
subscription["display_name"],
405-
)
402+
self.user = PartialUser(client._http, int(subscription["user_id"]), subscription["user_name"])
406403
except KeyError:
407404
self.user = None
408-
self.message = PubSubChatMessage(subscription["sub_message"]["message"])
405+
406+
self.message: str = subscription["sub_message"]["message"]
409407

410408
try:
411409
self.emotes = subscription["sub_message"]["emotes"]
@@ -415,9 +413,8 @@ def __init__(self, client: Client, topic: str, data: dict):
415413
self.is_gift: bool = subscription["is_gift"]
416414

417415
try:
418-
self.recipient = (
419-
PartialUser(client._http, subscription["recipient_user_name"], int(subscription["recipient_id"])),
420-
subscription["recipient_display_name"],
416+
self.recipient = PartialUser(
417+
client._http, int(subscription["recipient_id"]), subscription["recipient_user_name"]
421418
)
422419
except KeyError:
423420
self.recipient = None

0 commit comments

Comments
 (0)