(yarn): Add yarn module for one-off commands

This commit is contained in:
2026-07-22 17:32:29 +03:00
parent 280ef7fb64
commit ef7789dc9c
3 changed files with 29 additions and 1 deletions
+2 -1
View File
@@ -6,9 +6,10 @@ if TYPE_CHECKING:
async def twitch_setup(bot: "Bot"): async def twitch_setup(bot: "Bot"):
# Import and run setup methods from each module # Import and run setup methods from each module
from . import profiles, tracker, subathon, exec from . import profiles, tracker, subathon, exec, yarn
await profiles.twitch_setup(bot) await profiles.twitch_setup(bot)
await tracker.twitch_setup(bot) await tracker.twitch_setup(bot)
await subathon.twitch_setup(bot) await subathon.twitch_setup(bot)
await exec.twitch_setup(bot) await exec.twitch_setup(bot)
await yarn.twitch_setup(bot)
+7
View File
@@ -0,0 +1,7 @@
import logging
logger = logging.getLogger()
async def twitch_setup(bot):
from .component import YarnComponent
await bot.add_component(YarnComponent(bot))
+20
View File
@@ -0,0 +1,20 @@
import asyncio
import twitchio
from twitchio import PartialUser, Scopes, eventsub
from twitchio.ext import commands as cmds
from meta import Bot, Context
from . import logger
class YarnComponent(cmds.Component):
def __init__(self, bot: Bot):
self.bot = bot
@cmds.Component.listener()
async def event_custom_redemption_add(self, payload: twitchio.ChannelPointsRedemptionAdd):
logger.info(f"Yarn got {payload!r}")
if payload.reward.title == 'pet lilac':
await payload.broadcaster.send_message("lilac PETPET", sender="1097964183")