签到功能加入了总天数记录。
This commit is contained in:
@@ -74,4 +74,24 @@ class SignInRedisDB:
|
||||
redis_client.delete(key)
|
||||
return True
|
||||
except Exception:
|
||||
return False
|
||||
return False
|
||||
|
||||
def get_user_total_sign_count_key(self, wx_id: str, group_id: str) -> str:
|
||||
"""获取用户总签到次数的Redis键"""
|
||||
return f"{self.prefix}sign:total:{wx_id}:{group_id}"
|
||||
|
||||
def increment_user_sign_count(self, wx_id: str, group_id: str) -> int:
|
||||
"""增加用户签到总次数"""
|
||||
key = self.get_user_total_sign_count_key(wx_id, group_id)
|
||||
return self.redis.incr(key)
|
||||
|
||||
def get_user_total_sign_count(self, wx_id: str, group_id: str) -> int:
|
||||
"""获取用户签到总次数"""
|
||||
key = self.get_user_total_sign_count_key(wx_id, group_id)
|
||||
count = self.redis.get(key)
|
||||
return int(count) if count else 0
|
||||
|
||||
def set_user_total_sign_count(self, wx_id: str, group_id: str, count: int) -> bool:
|
||||
"""设置用户签到总次数"""
|
||||
key = self.get_user_total_sign_count_key(wx_id, group_id)
|
||||
return self.redis.set(key, count)
|
||||
Reference in New Issue
Block a user