OokamiPupV2/cmd_twitch/quote.py

47 lines
1.6 KiB
Python

# 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 <number>
-> Retrieves the specific quote by ID.
- !quote add <quote text>
-> Adds a new quote and replies with its quote number.
- !quote remove <number>
-> Removes the specified quote.
- !quote restore <number>
-> Restores a previously removed quote.
- !quote info <number>
-> 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)