# cmd_twitch/quote.py from twitchio.ext import commands from cmd_common import common_commands as cc from modules.utility import is_channel_live import globals def setup(bot): """ Registers the '!quote' command for Twitch. """ @bot.command(name="quote") async def cmd_quote(ctx: commands.Context): """ Handles the !quote command with multiple subcommands. Usage: - !quote -> Retrieves a random (non-removed) quote. - !quote -> Retrieves the specific quote by ID. - !quote add -> Adds a new quote and replies with its quote number. - !quote remove -> Removes the specified quote. - !quote restore -> Restores a previously removed quote. - !quote info -> Displays stored information about the quote. - !quote search [keywords] -> Searches for the best matching quote. - !quote last/latest/newest -> Retrieves the latest (most recent) non-removed quote. """ if not await is_channel_live(bot): if not globals.init_db_conn: await ctx.reply("Database is unavailable, sorry.") return args = ctx.message.content.strip().split()[1:] result = await cc.handle_quote_command( db_conn=globals.init_db_conn, is_discord=False, ctx=ctx, args=args ) await ctx.reply(result)