送积分,加分提醒

This commit is contained in:
liuwei
2025-06-03 12:11:27 +08:00
parent 20d535b4d7
commit 2c5cbcfecd

View File

@@ -32,6 +32,8 @@ def points_reward_decorator(points_calculator: Union[int, Callable], source_type
# 检查权限 # 检查权限
roomid = message.get("roomid", "") roomid = message.get("roomid", "")
bot: WechatAPIClient = message.get("bot")
revoke: MessageAutoRevoke = message.get("revoke")
if feature and roomid: if feature and roomid:
if GroupBotManager.get_group_permission(roomid, feature) == PermissionStatus.DISABLED: if GroupBotManager.get_group_permission(roomid, feature) == PermissionStatus.DISABLED:
return False, "没有权限" return False, "没有权限"
@@ -86,6 +88,11 @@ def points_reward_decorator(points_calculator: Union[int, Callable], source_type
# 如果响应中没有提到积分,添加积分信息 # 如果响应中没有提到积分,添加积分信息
if "积分" not in response: if "积分" not in response:
response += f"\n\n🎁 恭喜获得 {points} 积分奖励!" response += f"\n\n🎁 恭喜获得 {points} 积分奖励!"
client_msg_id, create_time, new_msg_id = await bot.send_at_message(
(roomid if roomid else sender),
response, [sender]
)
revoke.add_message_to_revoke(roomid, client_msg_id, create_time, new_msg_id, 5)
else: else:
logger.warning(f"用户 {sender} 积分奖励失败: {reward_result}") logger.warning(f"用户 {sender} 积分奖励失败: {reward_result}")
except Exception as e: except Exception as e: