调整连签提醒
This commit is contained in:
@@ -192,6 +192,8 @@ class SignInSystem:
|
|||||||
return
|
return
|
||||||
|
|
||||||
streak = 0
|
streak = 0
|
||||||
|
streak_broken = False
|
||||||
|
old_streak = 1
|
||||||
if user_record and user_record['sign_stat']:
|
if user_record and user_record['sign_stat']:
|
||||||
last_sign_date = user_record['sign_stat'].replace(hour=0, minute=0, second=0, microsecond=0)
|
last_sign_date = user_record['sign_stat'].replace(hour=0, minute=0, second=0, microsecond=0)
|
||||||
# 确保 sign_stat 和 today_start 是同一时区对象
|
# 确保 sign_stat 和 today_start 是同一时区对象
|
||||||
@@ -201,8 +203,11 @@ class SignInSystem:
|
|||||||
f"last_sign_date: {last_sign_date}, yesterday: {yesterday}, user_streak: {user_record['signin_streak']}")
|
f"last_sign_date: {last_sign_date}, yesterday: {yesterday}, user_streak: {user_record['signin_streak']}")
|
||||||
if last_sign_date == yesterday:
|
if last_sign_date == yesterday:
|
||||||
streak = user_record['signin_streak'] + 1
|
streak = user_record['signin_streak'] + 1
|
||||||
|
old_streak = streak
|
||||||
|
streak_broken = False
|
||||||
else:
|
else:
|
||||||
streak = 1
|
streak = 1
|
||||||
|
streak_broken = True
|
||||||
else:
|
else:
|
||||||
streak = 1
|
streak = 1
|
||||||
|
|
||||||
@@ -236,14 +241,21 @@ class SignInSystem:
|
|||||||
message.sender, message.roomid, wx_nick_name, points_to_add, current_time, streak
|
message.sender, message.roomid, wx_nick_name, points_to_add, current_time, streak
|
||||||
))
|
))
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
output = ("\n"
|
||||||
|
f"-----Bot-----\n"
|
||||||
|
f"@{wx_nick_name} 签到成功!\n"
|
||||||
|
f"签到成功!你领到了 {points_to_add} 个积分!✅\n"
|
||||||
|
f"你是今天第 {today_signin_rank} 个签到的!🎉\n")
|
||||||
|
|
||||||
|
if streak_broken and old_streak > 0: # 只有在真的断签且之前有签到记录时才显示
|
||||||
|
output += f"你断开了 {old_streak} 天的连续签到![心碎]"
|
||||||
|
elif streak > 1:
|
||||||
|
output += f"你连续签到了 {streak} 天!"
|
||||||
|
if streak > 1 and not streak_broken:
|
||||||
|
output += "[爱心]"
|
||||||
|
|
||||||
msg = (
|
|
||||||
f"@{wx_nick_name} 签到成功!\n"
|
|
||||||
f"您是今日群内第{today_signin_rank}个签到的\n"
|
|
||||||
f"连续签到{streak}天,本次获得{points_to_add}积分"
|
|
||||||
)
|
|
||||||
self.wcf.send_text(
|
self.wcf.send_text(
|
||||||
msg,
|
output,
|
||||||
(message.roomid if message.from_group() else message.sender),
|
(message.roomid if message.from_group() else message.sender),
|
||||||
message.sender
|
message.sender
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user