Compare commits

...

3 Commits

Author SHA1 Message Date
conatum 17c0dc00c1 fix(twitch): Pass context arguments correctly 2026-05-31 06:49:38 +10:00
conatum 1c1c109860 fix(twitch): Fix broken imports 2026-05-31 06:42:18 +10:00
conatum d1368af74b fix(data): Fix typos in schema 2026-05-31 06:42:12 +10:00
4 changed files with 12 additions and 8 deletions
+1 -2
View File
@@ -13,7 +13,7 @@ CREATE TABLE customcmds(
cooldown_bucket_dur INTEGER,
permlevel INTEGER,
maskperms BOOLEAN DEFAULT FALSE,
creatorid INTEGER NOT NULL REFERENCES profiles(profileid) ON DELETE CASCADE ON UPDATE CASCADE,
creatorid INTEGER NOT NULL REFERENCES user_profiles(profileid) ON DELETE CASCADE ON UPDATE CASCADE,
description TEXT,
docstring TEXT,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
@@ -52,7 +52,6 @@ SELECT
cmds.maskperms,
cmds.creatorid,
cmds.description,
cmds.description,
cmds.docstring,
cmds.created_at,
cmds._timestamp,
+1
View File
@@ -54,6 +54,7 @@ class TwitchCmdClient(ExecClient):
alias=maybe_command,
used_prefix=prefix,
message=message,
content=message.text,
initial_globals={
"author": CustomCmdUser(message.chatter),
"channel": CustomCmdUser(message.broadcaster),
+7 -3
View File
@@ -5,14 +5,15 @@ from twitchio import PartialUser
from twitchio.ext import commands as cmds
from meta import Bot
from twitch.client import TwitchCmdClient
from utils.lib import utc_now
from . import logger
from ..customcmd.data import CustomCmd, CustomCmdData
from ..customcmd.client import ExecClient
from ..customcmd.parser import ExecContext
from . import logger
from .client import TwitchCmdClient
# TODO: Make an alphacroc or croccyalpha client for testing
# TODO: Fix the tracker not actually guarding the commands properly
@@ -58,13 +59,16 @@ class CustomCmdComponent(cmds.Component):
# Make sure the command parses (can't guarantee it runs, but at least it can parse)
try:
await self.cmdclient.run_command(ExecContext(args=[], content=""), response)
await self.cmdclient.run_command(
ExecContext(alias="testing", args=[], content=""), response, dryrun=True
)
except Exception:
# TODO: Nicer errors for pinpointing problem
await ctx.reply(f"Sorry, could not parse your command!")
logger.info(
f"Failed to parse attempted customcmd '{response}'", exc_info=True
)
return
# If everything is good, add it to the table
# TODO: Again, permission resolution
+3 -3
View File
@@ -1,7 +1,7 @@
import twitchio
from meta import Bot
from utils.lib import utc_now, strfdur
from utils.lib import utc_now, strfdelta
from ..customcmd.parser import ExecContext
from ..customcmd.client import ExecClient
@@ -34,7 +34,7 @@ class CustomCmdUser:
followed_at = follower.followed_at
if followed_at:
durstr = strfdur(utc_now() - followed_at)
durstr = strfdelta(utc_now() - followed_at)
resp = (
f"{self.user.mention} has been following {channel.mention} for {durstr}"
)
@@ -59,7 +59,7 @@ class CustomContext(ExecContext):
used_prefix: str,
**kwargs,
):
super().__init__(**kwargs)
super().__init__(alias=alias, **kwargs)
self.bot = bot
self.message = message
self.alias = alias