Skip to content

Commit 8f60d63

Browse files
committed
Update forward.py
1 parent 699c302 commit 8f60d63

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

forward/forward.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,17 @@ async def _handle_automatic_unblock(self):
4646
await self.bot.wait_until_red_ready()
4747
while True:
4848
try:
49-
async with self.config.blocked() as blocked:
50-
for userid, until in blocked:
51-
now = datetime.now(timezone.utc).timestamp()
52-
log.debug("Checking if {} should be unblocked. Now: {}, Until: {}".format(userid, now, until))
53-
if now > until:
54-
del blocked[userid]
49+
await self._process_expired_blocks()
5550
except Exception:
5651
log.error("Error checking bot unblocks", exc_info=True)
5752
await asyncio.sleep(60) # 60 seconds
5853

54+
async def _process_expired_blocks(self):
55+
async with self.config.blocked() as blocked:
56+
for userid, until in blocked.items():
57+
if datetime.now(timezone.utc).timestamp() > until:
58+
del blocked[userid]
59+
5960
async def _destination(self, msg: str = None, embed: discord.Embed = None):
6061
await self.bot.wait_until_ready()
6162
channel = await self.config.destination()

0 commit comments

Comments
 (0)