Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/TwitchIO/TwitchIO
Browse files Browse the repository at this point in the history
  • Loading branch information
IAmTomahawkx committed Aug 28, 2023
2 parents b4dba3c + 097201e commit 8b631fb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
7 changes: 7 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
:orphan:

Master
======
- TwitchIO
- Bug fixes
- Fix IndexError when getting prefix when empty message is sent in a reply.


2.7.0
======
- TwitchIO
Expand Down
4 changes: 3 additions & 1 deletion twitchio/ext/commands/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ async def get_prefix(self, message):
prefixes = await self.__get_prefixes__(message)
message_content = message.content
if "reply-parent-msg-id" in message.tags:
message_content = message_content.split(" ", 1)[1]
message_content = " ".join(message.content.split(" ")[1:])
else:
message_content = message.content
if not isinstance(prefixes, str):
for prefix in prefixes:
if message_content.startswith(prefix):
Expand Down
13 changes: 11 additions & 2 deletions twitchio/ext/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,6 @@ async def invoke(self, context: Context, *, index=0) -> None:
# TODO Docs
if not context.view:
return
args, kwargs = await self.parse_args(context, self._instance, context.view.words, index=index)
context.args, context.kwargs = args, kwargs

async def try_run(func, *, to_command=False):
try:
Expand All @@ -213,6 +211,17 @@ async def try_run(func, *, to_command=False):
else:
context.bot.run_event("command_error", context, _e)

try:
args, kwargs = await self.parse_args(context, self._instance, context.view.words, index=index)
except (MissingRequiredArgument, BadArgument) as e:
if self.event_error:
args_ = [self._instance, context] if self._instance else [context]
await try_run(self.event_error(*args_, e))

context.bot.run_event("command_error", context, e)
return

context.args, context.kwargs = args, kwargs
check_result = await self.handle_checks(context)

if check_result is not True:
Expand Down
4 changes: 3 additions & 1 deletion twitchio/ext/routines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,9 @@ async def _routine(self, *args, **kwargs) -> None:
if self._remaining_iterations == 0:
self._remaining_iterations = self._iterations

iteration: int = 0
while True:
iteration += 1
start = datetime.datetime.now(datetime.timezone.utc)

try:
Expand All @@ -387,7 +389,7 @@ async def _routine(self, *args, **kwargs) -> None:
break

if self._time:
sleep = compute_timedelta(self._time + datetime.timedelta(days=self._completed_loops))
sleep = compute_timedelta(self._time + datetime.timedelta(days=iteration))
else:
sleep = max((start - datetime.datetime.now(datetime.timezone.utc)).total_seconds() + self._delta, 0)

Expand Down

0 comments on commit 8b631fb

Please sign in to comment.