tweak: Add inactive redeem event listener

This commit is contained in:
2026-07-31 13:23:42 +03:00
parent 14134d8831
commit 97bdf8e8e3
2 changed files with 42 additions and 6 deletions
+36 -3
View File
@@ -80,10 +80,43 @@ class CampaignComponent(cmds.Component):
twitch_user_name=data["chatter_user_name"],
)
await self.dispatch_update(campaign)
# TODO: Webhook logging maybe.. (do this in campaign)
# Or just general logging. (also do this in campaign, but we can do again here)
@cmds.Component.listener()
# @cmds.Component.listener()
async def event_custom_redemption_add(self, payload):
if payload.reward.title not in (
"hi!",
"hydrate",
"stretch",
"save file",
"pet lilac",
):
return
community = await self.bot.profiles.fetch_community(payload.broadcaster)
cid = community.communityid
profile = await self.bot.profiles.fetch_profile(payload.user)
pid = profile.profileid
campaigns = await self.campaigns.fetch_campaigns(cid)
for campaign in campaigns:
reward_progress = len(await campaign.get_rewards())
if (
campaign.row.target_rewards is None
or reward_progress < campaign.row.target_rewards
):
# Add a reward to the database with the correct info.
await campaign.add_reward(
profileid=pid,
earned_from=f"(REDEEM) User redeemed {payload.reward.title}",
event_id=None,
twitch_user_id=payload.user.id,
twitch_user_name=payload.user.name,
reference=f"Redeem text: {payload.user_input}",
)
await self.dispatch_update(campaign)
# @cmds.Component.listener()
async def event_message(self, payload):
if not payload.text.startswith("%reward%"):
return