调整我的积分格式,更加美观

This commit is contained in:
liuwei
2025-04-16 17:19:17 +08:00
parent 4ef042f179
commit fb70e48c1a
2 changed files with 25 additions and 207 deletions

View File

@@ -263,24 +263,39 @@ class PointTradePlugin(MessagePluginInterface):
source_stats[source] = 0
source_stats[source] += points
# 构建积分详情消息
source_details = "\n".join([f"- {source}: {points}" for source, points in source_stats.items()])
# 构建积分详情消息 - 优化格式
source_icons = {
"sign": "📝", "game": "🎮", "trade": "💱",
"rob": "🔫", "bailout": "🔓", "其他": "🔄"
}
source_details = []
for source, points in source_stats.items():
icon = source_icons.get(source, "")
sign = "+" if points > 0 else ""
source_details.append(f"{icon} {source}: {sign}{points}")
source_text = " | ".join(source_details) if source_details else "暂无记录"
# 构建最近交易记录
# 构建最近交易记录 - 优化格式
recent_txs = ""
if transactions:
recent_txs = "\n最近交易记录:\n"
recent_txs = "\n━━━ 最近交易 ━━━\n"
for i, tx in enumerate(transactions[:5], 1):
tx_type = "获得" if tx.get('points', 0) > 0 else "消费"
is_positive = tx.get('points', 0) > 0
tx_icon = "📈" if is_positive else "📉"
tx_type = "+" if is_positive else "-"
points = abs(tx.get('points', 0))
desc = tx.get('description', '无描述')
date = tx.get('created_at', '').strftime('%m-%d %H:%M') if tx.get('created_at') else '未知时间'
recent_txs += f"{i}. {date} {tx_type} {points} 积分 - {desc}\n"
date = tx.get('created_at', '').strftime('%m/%d %H:%M') if tx.get('created_at') else '未知'
recent_txs += f"{tx_icon} {date} {tx_type}{points} {desc}\n"
# 构建更Compact美观的输出
output = (
f"📊 {user_name} 的积分详情\n"
f"总积分: {user_points.get('total_points', 0)}\n"
f"\n积分来源统计:\n{source_details}"
f"💰 {user_name} 的积分\n"
f"━━━━━━━━━━━━━━\n"
f"💵 当前积分: {user_points.get('total_points', 0)}\n"
f"📊 积分来源: {source_text}"
f"{recent_txs}"
)