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