@@ -3200,12 +3200,16 @@ async def main() -> None:
3200
3200
simply: ``len(subscriptons) / max_per_shard`` or ``2`` whichever is greater. Note this parameter has no effect when
3201
3201
``shard_ids`` is explicitly passed.
3202
3202
subscriptions: list[twitchio.eventsub.SubscriptionPayload]
3203
- A list of any combination of EventSub subscriptions (all of which inherit from
3203
+ An optional list of any combination of EventSub subscriptions (all of which inherit from
3204
3204
:class:`~twitchio.eventsub.SubscriptionPayload`) the Client should attempt to subscribe to when required. The
3205
3205
:class:`~twitchio.AutoClient` will only attempt to subscribe to these subscriptions when it creates a new Conduit. If
3206
3206
your Client connects to an existing Conduit either by passing ``conduit_id`` or automatically, this parameter has no
3207
3207
effect. In cases where you need to update an existing Conduit with new subscriptions see:
3208
- :meth:`~twitchio.AutoClient.multi_subscribe`.
3208
+ :meth:`~twitchio.AutoClient.multi_subscribe` or the parameter ``force_subscribe``.
3209
+ force_subscribe: bool
3210
+ An optional :class:`bool` which when ``True`` will force attempt to subscribe to the subscriptions provided in the
3211
+ ``subscriptions`` parameter, regardless of whether a new conduit was created or not. Defaults to ``False``.
3212
+
3209
3213
"""
3210
3214
3211
3215
# NOTE:
@@ -3225,6 +3229,8 @@ def __init__(
3225
3229
) -> None :
3226
3230
self ._shard_ids : list [int ] = kwargs .pop ("shard_ids" , [])
3227
3231
self ._conduit_id : str | bool | None = kwargs .pop ("conduit_id" , MISSING )
3232
+ self ._force_sub : bool = kwargs .pop ("force_subscribe" , False )
3233
+ self ._subbed : bool = False
3228
3234
3229
3235
if self ._conduit_id is MISSING or self ._conduit_id is None :
3230
3236
logger .warning (
@@ -3353,6 +3359,9 @@ async def _setup(self) -> None:
3353
3359
raise MissingConduit ("No conduit could be found with the provided ID or a new one can not be created." )
3354
3360
3355
3361
await self ._associate_shards (self ._shard_ids )
3362
+ if self ._force_sub and not self ._subbed :
3363
+ await self .multi_subscribe (self ._initial_subs )
3364
+
3356
3365
await self .setup_hook ()
3357
3366
3358
3367
self ._setup_called = True
@@ -3484,6 +3493,7 @@ async def _generate_new_conduit(self) -> Conduit:
3484
3493
if self ._initial_subs :
3485
3494
logger .info ("Attempting to do an initial subscription on new conduit: %r." , self ._conduit_info )
3486
3495
await self ._multi_sub (self ._initial_subs , stop_on_error = False )
3496
+ self ._subbed = True
3487
3497
3488
3498
return new
3489
3499
0 commit comments