Skip to content

Commit

Permalink
user idol calls are not reset every 24h properly
Browse files Browse the repository at this point in the history
  • Loading branch information
MujyKun committed Aug 16, 2021
1 parent 1c43186 commit a179b23
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions IreneUtility/util/u_groupmembers.py
Original file line number Diff line number Diff line change
Expand Up @@ -867,8 +867,17 @@ async def idol_post(self, channel, idol, **kwargs):
return msg, image_host

def check_reset_limits(self):
"""Checks if the user idol calls needs to be reset back to 0."""
if time.time() - self.ex.cache.last_idol_reset_time > 86400: # 1 day in seconds
self.ex.cache.last_idol_reset_time = time.time() # reset the time
# reset user idol calls.
await self.ex.run_blocking_code(self.reset_user_idol_calls)

def reset_user_idol_calls(self):
"""Resets all user idol calls to zero."""
users = self.ex.cache.users.copy()
for user in users.values():
user.idol_calls = 0

# noinspection PyPep8
async def check_user_limit(self, message_sender, message_channel, no_vote_limit=False):
Expand Down

0 comments on commit a179b23

Please sign in to comment.