aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Matteo Bertucci <[email protected]>2021-05-15 18:53:27 +0200
committerGravatar Matteo Bertucci <[email protected]>2021-05-15 18:53:27 +0200
commitb5f56689fc88e569c61f7f24762c5228ed59566e (patch)
treec52d1952eed9c8acea2116dee59765a3881aec1d
parentNomination: change archive timestamp to %Y/%m/%d (diff)
Nomination: consider that the first message has two role pings
-rw-r--r--bot/exts/recruitment/talentpool/_review.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/bot/exts/recruitment/talentpool/_review.py b/bot/exts/recruitment/talentpool/_review.py
index 483354869..e895c2a4d 100644
--- a/bot/exts/recruitment/talentpool/_review.py
+++ b/bot/exts/recruitment/talentpool/_review.py
@@ -34,6 +34,8 @@ MAX_MESSAGE_SIZE = 2000
# Regex finding the user ID of a user mention
MENTION_RE = re.compile(r"<@!?(\d+?)>")
+# Regex matching role pings
+ROLE_MENTION_RE = re.compile(r"<@&\d+>")
class Reviewer:
@@ -134,15 +136,17 @@ class Reviewer:
"""Archive this vote to #nomination-archive."""
message = await message.fetch()
- # We consider that if a message has been sent less than 2 second before the one being archived
- # it is part of the same nomination.
- # For that we try to get messages sent in this timeframe until none is returned and NoMoreItems is raised.
+ # We consider the first message in the nomination to contain the two role pings
messages = [message]
- with contextlib.suppress(NoMoreItems):
- async for new_message in message.channel.history(before=message.created_at):
- if messages[-1].created_at - new_message.created_at > timedelta(seconds=2):
- break
- messages.append(new_message)
+ if not len(ROLE_MENTION_RE.findall(message.content)) >= 2:
+ with contextlib.suppress(NoMoreItems):
+ async for new_message in message.channel.history(before=message.created_at):
+ messages.append(new_message)
+
+ if len(ROLE_MENTION_RE.findall(new_message.content)) >= 2:
+ break
+
+ log.debug(f"Found {len(messages)} messages: {', '.join(str(m.id) for m in messages)}")
parts = []
for message_ in messages[::-1]: