generated from HoloTech/holotech-plugin-template
tweak: Add inactive redeem event listener
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user