fix(twitch): Fix relative imports
This commit is contained in:
+15
-15
@@ -2,23 +2,21 @@ from typing import Optional
|
||||
|
||||
import twitchio
|
||||
from twitchio import PartialUser
|
||||
from twitchio.ext import commands as cmds
|
||||
from twitchio.ext import commands as cmds
|
||||
|
||||
from customcmd.parser.context import ExecContext
|
||||
from meta import Bot
|
||||
from twitch.client import TwitchCmdClient
|
||||
from utils.lib import utc_now
|
||||
|
||||
from . import logger
|
||||
from . import logger
|
||||
from ..customcmd.data import CustomCmd, CustomCmdData
|
||||
from ..customcmd.client import ExecClient
|
||||
from ..customcmd.parser import ExecContext
|
||||
|
||||
# TODO: Make an alphacroc or croccyalpha client for testing
|
||||
# TODO: Fix the tracker not actually guarding the commands properly
|
||||
|
||||
|
||||
|
||||
|
||||
class CustomCmdComponent(cmds.Component):
|
||||
def __init__(self, bot: Bot):
|
||||
self.bot = bot
|
||||
@@ -31,11 +29,11 @@ class CustomCmdComponent(cmds.Component):
|
||||
await self.bot.version_check(*self.data.VERSION)
|
||||
|
||||
async def component_teardown(self):
|
||||
pass
|
||||
pass
|
||||
|
||||
# ----- Methods -----
|
||||
# ----- Methods -----
|
||||
|
||||
# ----- Event handlers -----
|
||||
# ----- Event handlers -----
|
||||
@cmds.Component.listener()
|
||||
async def event_message(self, payload: twitchio.ChatMessage):
|
||||
await self.cmdclient.process_message(payload)
|
||||
@@ -44,9 +42,9 @@ class CustomCmdComponent(cmds.Component):
|
||||
@cmds.group(name="commands")
|
||||
async def cmd_grp(self, ctx: cmds.Context):
|
||||
# TODO: Probably attempt to list commands or something here.
|
||||
pass
|
||||
pass
|
||||
|
||||
@cmd_grp.command(name="add", aliases=('create', 'new'))
|
||||
@cmd_grp.command(name="add", aliases=("create", "new"))
|
||||
@cmds.is_broadcaster() # TODO: Better command creation perm checks
|
||||
async def cmd_add(self, ctx: cmds.Context, name: str, *, response: str):
|
||||
comm = await self.bot.profiles.fetch_community(ctx.broadcaster)
|
||||
@@ -60,11 +58,13 @@ 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(args=[], content=""), response)
|
||||
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)
|
||||
logger.info(
|
||||
f"Failed to parse attempted customcmd '{response}'", exc_info=True
|
||||
)
|
||||
|
||||
# If everything is good, add it to the table
|
||||
# TODO: Again, permission resolution
|
||||
@@ -79,10 +79,10 @@ class CustomCmdComponent(cmds.Component):
|
||||
|
||||
await ctx.reply(f"Created a new command !{name}")
|
||||
|
||||
@cmd_grp.command(name="del", aliases=('delete', 'remove', 'rm'))
|
||||
@cmds.is_broadcaster()
|
||||
@cmd_grp.command(name="del", aliases=("delete", "remove", "rm"))
|
||||
@cmds.is_broadcaster()
|
||||
async def cmd_del(self, ctx: cmds.Context, name: str):
|
||||
# Lookup the name to make sure a command does exist
|
||||
# Lookup the name to make sure a command does exist
|
||||
# Delete the command (again, consider permissions later)
|
||||
# Confirm with user.
|
||||
comm = await self.bot.profiles.fetch_community(ctx.broadcaster)
|
||||
|
||||
Reference in New Issue
Block a user