Skip to content

Commit 0f0d449

Browse files
committed
Invoke command in threads fix join_channels bug
Commands will now be invoked in replies and threads. Channels prefixed with # in initial_channels will now trigger event_ready correctly.
1 parent bcb4439 commit 0f0d449

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

docs/changelog.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ Master
44
=======
55
Massive documentation updates
66

7+
- TwitchIO
8+
- Fix bug where # prefixed channel names in initial_channels would not trigger :func:`Client.event_ready``
9+
10+
- ext.commands
11+
- :func:`Bot.handle_commands` now also invokes on threads / replies
12+
13+
714
2.2.0
815
=====
916
- ext.sounds
@@ -30,7 +37,7 @@ Massive documentation updates
3037
- ext.eventsub
3138
- Add support for the following subscription types
3239
- :class:`twitchio.ext.eventsub.PollBeginProgressData`
33-
- ``channel.poll.begin``:
40+
- ``channel.poll.begin``:
3441
- ``channel.poll.progress``
3542
- :class:`twitchio.ext.eventsub.PollEndData`
3643
- ``channel.poll.end``

twitchio/ext/commands/bot.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,21 @@ async def get_context(self, message, *, cls=None):
323323
return context
324324

325325
async def handle_commands(self, message):
326+
"""|coro|
327+
328+
This method handles commands sent from chat and invokes them.
329+
330+
By default, this coroutine is called within the `event_message` event.
331+
If you choose to override `event_message` then you need to invoke this coroutine in order to handle commands.
332+
333+
Parameters
334+
----------
335+
message: :class:`.Message`
336+
The message object to get content of and context for.
337+
338+
"""
339+
if "reply-parent-msg-id" in message.tags:
340+
message.content = message.content.split(" ")[1]
326341
context = await self.get_context(message)
327342
await self.invoke(context)
328343

twitchio/websocket.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,12 +352,12 @@ async def _code(self, parsed, code: int):
352352
if parsed["channel"] == "TWITCHIOFAILURE":
353353
self._initial_channels.remove(parsed["batches"][0])
354354

355-
if parsed["channel"] in [c.lower() for c in self._initial_channels] and not self._init:
355+
if parsed["channel"] in [c.lower().lstrip("#") for c in self._initial_channels] and not self._init:
356356
self._join_load[parsed["channel"]] = None
357357

358358
if len(self._join_load) == len(self._initial_channels):
359359
for channel in self._initial_channels:
360-
self._join_load.pop(channel.lower())
360+
self._join_load.pop(channel.lower().lstrip("#"))
361361
self._cache_add(parsed)
362362
self.is_ready.set()
363363
else:

0 commit comments

Comments
 (0)