fix(twitch): Fix relative imports

This commit is contained in:
2026-05-31 06:32:31 +10:00
parent 733f3e3ae6
commit 0d4f9b9a9a
3 changed files with 46 additions and 46 deletions
+14 -15
View File
@@ -1,11 +1,13 @@
import twitchio
from customcmd.client import ExecClient
from customcmd.data import CustomCmd, CustomCmdData
from meta import Bot
from ..customcmd.client import ExecClient
from ..customcmd.data import CustomCmd, CustomCmdData
from .context import CustomContext, CustomCmdUser
class TwitchCmdClient(ExecClient):
def __init__(self, bot: Bot, data: CustomCmdData):
super().__init__()
@@ -22,12 +24,12 @@ class TwitchCmdClient(ExecClient):
if message.reply:
# Strip the hidden mention prefix from the start of the message
prefix = message.reply.parent_user.mention
content = content[len(prefix) + 1:]
content = content[len(prefix) + 1 :]
# If we start with a valid prefix, parse out a command name
# If we start with a valid prefix, parse out a command name
if prefix := next((p for p in prefixes if content.startswith(p)), None):
# Strip the valid prefix
content = content[len(prefix):].strip()
content = content[len(prefix) :].strip()
if not content:
# Exit early, no command
return
@@ -45,7 +47,7 @@ class TwitchCmdClient(ExecClient):
# Read the arguments, build the context, run the command.
# TODO: Check the permissions and log etc.
# TODO: Exception handling, as usual
# TODO: Nice string reprs
# TODO: Nice string reprs
ctx = CustomContext(
bot=self.bot,
args=args,
@@ -53,20 +55,17 @@ class TwitchCmdClient(ExecClient):
used_prefix=prefix,
message=message,
initial_globals={
'author': CustomCmdUser(message.chatter),
'channel': CustomCmdUser(message.broadcaster),
}
"author": CustomCmdUser(message.chatter),
"channel": CustomCmdUser(message.broadcaster),
},
)
result = await self.run_command(ctx, cmd.response)
if result:
await message.broadcaster.send_message(
result,
sender=self.bot.user
)
await message.broadcaster.send_message(result, sender=self.bot.user)
async def get_prefixes(self, message: twitchio.ChatMessage):
# TODO:
return ('!',)
# TODO:
return ("!",)
async def get_commands_in(self, communityid: int) -> dict[str, CustomCmd]:
"""