调整连签加积分数量。
This commit is contained in:
@@ -171,19 +171,19 @@ class MessageSignPlugin(MessagePluginInterface):
|
|||||||
# 获取用户的签到记录
|
# 获取用户的签到记录
|
||||||
user_record = self.get_user_record(sender, roomid)
|
user_record = self.get_user_record(sender, roomid)
|
||||||
|
|
||||||
# 计算连续签到天数
|
# 直接使用用户当前的连续签到天数,而不是重新计算
|
||||||
streak = 1
|
# 这个值已经在 _handle_sign_in 方法中被正确更新
|
||||||
if user_record and user_record['sign_stat']:
|
if "签到成功" in response:
|
||||||
last_sign_date = user_record['sign_stat'].replace(hour=0, minute=0, second=0, microsecond=0)
|
# 从响应中提取连续签到天数
|
||||||
# 确保 sign_stat 和 today_start 是同一时区对象
|
streak = 1 # 默认为1天
|
||||||
if isinstance(last_sign_date, datetime) and last_sign_date.tzinfo is None:
|
if user_record:
|
||||||
last_sign_date = pytz.timezone(self.timezone).localize(last_sign_date)
|
# 使用数据库中已更新的连签天数
|
||||||
|
streak = user_record.get('signin_streak', 1)
|
||||||
if last_sign_date == yesterday:
|
# 如果今天刚签到,连签天数已经+1,所以这里不需要再加1
|
||||||
streak = user_record['signin_streak'] + 1
|
|
||||||
|
# 计算积分
|
||||||
# 计算积分
|
points = self.calculate_points(streak)
|
||||||
points = self.calculate_points(streak)
|
|
||||||
return points
|
return points
|
||||||
|
|
||||||
# 修改 process_message 方法,作为路由分发
|
# 修改 process_message 方法,作为路由分发
|
||||||
|
|||||||
Reference in New Issue
Block a user