aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2019-10-11 14:50:16 -0700
committerGravatar MarkKoz <[email protected]>2019-10-11 14:50:16 -0700
commitd8f851634e67ee4cecb63cb29001669064518ff6 (patch)
tree9de47ec591d888f15a6fcdd1cac1607918db1b57
parentCancel the periodic ping task when the verification cog is unloaded (diff)
Revise comments and the doctsring for the periodic ping function
-rw-r--r--bot/cogs/verification.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/bot/cogs/verification.py b/bot/cogs/verification.py
index 74e1b333b..491e74076 100644
--- a/bot/cogs/verification.py
+++ b/bot/cogs/verification.py
@@ -165,18 +165,21 @@ class Verification(Cog):
@tasks.loop(hours=12)
async def periodic_ping(self) -> None:
- """Post a recap message every week with an @everyone."""
- messages = self.bot.get_channel(Channels.verification).history(limit=10) # check lasts messages
- need_to_post = True # if the bot has to post a new message in the channel
+ """Every week, mention @everyone to remind them to verify."""
+ messages = self.bot.get_channel(Channels.verification).history(limit=10)
+ need_to_post = True # True if a new message needs to be sent.
+
async for message in messages:
- if message.content == PERIODIC_PING: # to be sure to measure timelaps between two identical messages
- delta = datetime.utcnow() - message.created_at # time since last periodic ping
- if delta.days >= 7: # if the message is older than a week
+ if message.content == PERIODIC_PING:
+ delta = datetime.utcnow() - message.created_at # Time since last message.
+ if delta.days >= 7: # Message is older than a week.
await message.delete()
else:
need_to_post = False
+
break
- if need_to_post: # if the bot did not posted yet
+
+ if need_to_post:
await self.bot.get_channel(Channels.verification).send(PERIODIC_PING)
@periodic_ping.before_loop