From 45ba8b159309a22bc0b3f107a67e3049e51b04b4 Mon Sep 17 00:00:00 2001 From: Chris Angelico Date: Mon, 2 Dec 2024 17:23:18 +1100 Subject: [PATCH] pointsmgr: Provide @mod/@vip/@sub in point redemptions too, using the most recently seen --- modules/pointsmgr.pike | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/modules/pointsmgr.pike b/modules/pointsmgr.pike index 6d0efa9e..266158bb 100644 --- a/modules/pointsmgr.pike +++ b/modules/pointsmgr.pike @@ -30,14 +30,19 @@ __async__ void points_redeemed(object channel, mapping data, int|void removal) { (["method": "PATCH", "json": (["cost": newcost])]), ); } - if (channel && !removal) foreach (channel->redemption_commands[data->reward->id] || ({ }), string cmd) { - channel->send(([ - "displayname": data->user_name, "user": data->user_login, - "uid": data->user_id, - ]), channel->commands[cmd], ([ - "%s": data->user_input, - "{rewardid}": data->reward->id, "{redemptionid}": data->id, - ])); + if (channel && !removal) { + mapping badges = channel->user_badges[data->user_id] || ([]); + foreach (channel->redemption_commands[data->reward->id] || ({ }), string cmd) { + channel->send(([ + "displayname": data->user_name, "user": data->user_login, + "uid": data->user_id, + ]), channel->commands[cmd], ([ + "%s": data->user_input, + "{rewardid}": data->reward->id, "{redemptionid}": data->id, + "{@mod}": badges->?_mod ? "1" : "0", "{@sub}": badges->?_sub ? "1" : "0", + "{@vip}": badges->?vip ? "1" : "0", + ])); + } } }