动态积分!
This commit is contained in:
@@ -553,7 +553,7 @@ class PointTradePlugin(MessagePluginInterface):
|
||||
f"🚨 打劫失败!\n"
|
||||
f"👤{robber_name} 试图打劫 👤{target_name} 但被当场抓获,并赔款!\n"
|
||||
f"👮♂️ 被罚款 {penalty_amount} 积分!\n"
|
||||
f"👤{robber_name} 当前积分: {to_user.get('total_points', 0)}"
|
||||
f"👤{robber_name} 当前积分: {from_user.get('total_points', 0)}"
|
||||
)
|
||||
|
||||
wcf.send_text(output, roomid, sender)
|
||||
|
||||
@@ -134,14 +134,21 @@ def plugin_points_cost(points: int, description: str = None, feature: Feature =
|
||||
logger = logging.getLogger(f"PointsCost.{plugin_name}")
|
||||
|
||||
user_points = points_db.get_user_points(sender, roomid)
|
||||
if user_points["total_points"] < points:
|
||||
stats = points_db.get_user_points_stats(roomid)
|
||||
try:
|
||||
points_auto = int(points * stats["total_points"] / 1000)
|
||||
except Exception as e:
|
||||
logger.error(f"计算抵扣积分错误,使用默认积分:{e}")
|
||||
points_auto = points
|
||||
|
||||
if user_points["total_points"] < points_auto:
|
||||
# 积分不足
|
||||
wcf = message.get("wcf")
|
||||
if wcf:
|
||||
wcf.send_text(
|
||||
f"❌ 积分不足\n无法使用 {plugin_name} 功能\n"
|
||||
f"🪙 先参与积分活动[签到,答题/t]赚取吧!\n"
|
||||
f"💰 有: {user_points['total_points']} | 需: {points} |差: {points - user_points['total_points']} ",
|
||||
f"💰 有: {user_points['total_points']} | 需: {points_auto} |差: {points_auto - user_points['total_points']} ",
|
||||
(roomid if roomid else sender), sender
|
||||
)
|
||||
logger.info(f"用户 {sender} 积分不足,无法使用功能")
|
||||
@@ -153,20 +160,20 @@ def plugin_points_cost(points: int, description: str = None, feature: Feature =
|
||||
# 如果原始方法执行成功,扣除积分
|
||||
if success:
|
||||
deduct_success, deduct_result = points_db.deduct_points(
|
||||
sender, roomid, points, PointSource.PLUGIN,
|
||||
sender, roomid, points_auto, PointSource.PLUGIN,
|
||||
description or f"使用 {plugin_name} 功能"
|
||||
)
|
||||
|
||||
if deduct_success:
|
||||
logger.info(f"用户 {sender} 使用 {plugin_name} 功能扣除 {points} 积分")
|
||||
logger.info(f"用户 {sender} 使用 {plugin_name} 功能扣除 {points_auto} 积分")
|
||||
|
||||
# 如果响应中没有提到积分,添加积分信息
|
||||
if "积分" not in response:
|
||||
response += f"\n\n💰 已消费 {points} 积分"
|
||||
response += f"\n\n💰 已消费 {points_auto} 积分"
|
||||
wcf = message.get("wcf")
|
||||
if wcf:
|
||||
wcf.send_text(
|
||||
f"💰消费 {points} 积分",
|
||||
f"💰消费 {points_auto} 积分",
|
||||
(roomid if roomid else sender), sender
|
||||
)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user