Skip to content

Commit c882f54

Browse files
authored
Update incredibly wrong docstrings for new hooks
1 parent 11cf32e commit c882f54

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

twitchio/ext/pubsub/pool.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,20 +104,32 @@ async def _process_auth_fail(self, nonce: str, node: PubSubWebsocket) -> None:
104104
logger.error("Error occurred while calling auth_fail_hook.", exc_info=e)
105105

106106
async def auth_fail_hook(self, topics: List[Topic]):
107-
"""
107+
"""|coro|
108108
This is a hook that can be overridden in a subclass.
109+
From this hook, you can refresh expired tokens (or prompt a user for new ones), and resubscribe to the events.
110+
111+
.. note::
112+
113+
The topics will not be automatically resubscribed to. You must do it yourself by calling :meth:`~PubSubPool.subscribe_topics` with the topics after obtaining new tokens.
114+
115+
An example of what this method should do:
116+
117+
.. code:: python
118+
119+
class MyPubSubPool(pubsub.PubSubPool):
120+
async def auth_fail_hook(self, topics: List[pubsub.Topic]):
121+
token = topics[0].token
122+
new_token = await some_imaginary_function_that_refreshes_tokens(token)
109123
124+
for topic in topics:
125+
topic.token = new_token
110126
127+
await self.subscribe_topics(topics)
128+
111129
Parameters
112130
----------
113-
node
114131
topics: List[:class:`Topic`]
115-
The topcs that this node has.
116-
117-
Returns
118-
-------
119-
List[:class:`Topic`]
120-
The list of topics this node should have. Any additions, modifications, or removals will be respected.
132+
The topics that have been deauthorized. Typically these will all contain the same token.
121133
"""
122134

123135
async def _process_reconnect_hook(self, node: PubSubWebsocket) -> None:
@@ -145,9 +157,10 @@ async def reconnect_hook(self, node: PubSubWebsocket, topics: List[Topic]) -> Li
145157
146158
Parameters
147159
----------
148-
node
160+
node: :class:`PubSubWebsocket`
161+
The node that is reconnecting.
149162
topics: List[:class:`Topic`]
150-
The topcs that this node has.
163+
The topics that this node has.
151164
152165
Returns
153166
-------

0 commit comments

Comments
 (0)