Skip to content

Add Modpings cog and new Moderators role#1526

Merged
mbaruh merged 17 commits into
mainfrom
mbaruh/offduty
Apr 20, 2021
Merged

Add Modpings cog and new Moderators role#1526
mbaruh merged 17 commits into
mainfrom
mbaruh/offduty

Conversation

@mbaruh
Copy link
Copy Markdown
Member

@mbaruh mbaruh commented Apr 14, 2021

Added a cog to allow moderators to turn pings off and back on.
The off state is cached via a redis cache, and its expiry is scheduled via the Scheduler.

Additionally changes which roles are pinged on mod alerts to the new role.

image

Added a cog to allow moderators to go off and on duty.
The off-duty state is cached via a redis cache, and its expiry is scheduled via the Scheduler.

Additionally changes which roles are pinged on mod alerts.
@mbaruh mbaruh added a: moderation Related to community moderation functionality: (moderation, defcon, verification) p: 1 - high High Priority t: feature New feature or request labels Apr 14, 2021
ks129
ks129 previously requested changes Apr 14, 2021

# RedisCache[str, str]
# The cache's keys are mods who are off-duty.
# The cache's values are the times when the role should be re-applied to them, stored in ISO format.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember Mark said somewhere else that using Unix timestamp is better.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a specific reason? in terms of functionality it seems to work just fine.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A previous discussion on that is here, although I feel it's fine either way.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I would prefer timestamps over formatted strings (now for consistency too since it's a more established pattern) but it's not a dealbreaker.

Comment thread bot/exts/moderation/duty.py Outdated
Comment thread bot/exts/moderation/duty.py Outdated
Comment thread bot/exts/moderation/duty.py Outdated
Comment thread bot/exts/moderation/duty.py Outdated
@mbaruh mbaruh requested a review from ks129 April 16, 2021 13:11
Copy link
Copy Markdown
Contributor

@HassanAbouelela HassanAbouelela left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a solid PR. I just had a couple questions, but otherwise this is good to go.

Comment thread config-default.yml
Comment thread bot/exts/moderation/modlog.py Outdated
Copy link
Copy Markdown
Contributor

@MarkKoz MarkKoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't there also everyone pings for filters and antispam? Do those also need to be changed to be like the modlog ping?

Comment thread bot/exts/moderation/duty.py Outdated
mod = ctx.author

until_date = duration.replace(microsecond=0).isoformat()
await mod.remove_roles(self.moderators_role, reason=f"Entered off-duty period until {until_date}.")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the user doesn't have the role (i.e. they're already off-duty)? Will this raise an exception or fail silently?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my tests it fails silently

Comment on lines +102 to +103
if mod.id in self._role_scheduler:
self._role_scheduler.cancel(mod.id)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this done to allow a user to extend their off-duty period while they're already off-duty?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, or not necessarily extend it, but just change it without having to cancel it first.

Comment thread bot/exts/moderation/duty.py Outdated
Comment thread bot/exts/moderation/duty.py
Comment thread bot/exts/moderation/duty.py Outdated
mbaruh added 4 commits April 17, 2021 01:15
A moderator is expected to have the mod-team role and therefore it's enough to specify the latter in the mod and staff roles.
The lack of such a task may be indicative of a bug.
@mbaruh
Copy link
Copy Markdown
Member Author

mbaruh commented Apr 16, 2021

@MarkKoz from what I see and my tests, the filters and antispam use the modlog method for the alert, so this change should handle everything.

@mbaruh mbaruh requested a review from MarkKoz April 16, 2021 23:02
Kinda defeats the purpose of being off-duty.
@mbaruh mbaruh requested a review from HassanAbouelela April 17, 2021 10:22
@mbaruh mbaruh changed the title Add Duty cog and new Moderators role Add Modpings cog and new Moderators role Apr 19, 2021
Comment thread bot/exts/moderation/modpings.py Outdated
Copy link
Copy Markdown
Member

@ChrisLovering ChrisLovering left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment which might help readability, but looks good to me otherwise!

Comment thread bot/exts/moderation/modpings.py Outdated
Comment thread bot/exts/moderation/modlog.py
mbaruh and others added 3 commits April 20, 2021 18:48
Co-authored-by: ChrisJL <ChrisLovering@users.noreply.github.com>
The modlog alert embed no longer pings everyone.
@mbaruh mbaruh dismissed stale reviews from HassanAbouelela and ks129 April 20, 2021 16:17

Stale

@mbaruh mbaruh merged commit 0b23ffb into main Apr 20, 2021
@mbaruh mbaruh deleted the mbaruh/offduty branch April 20, 2021 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: moderation Related to community moderation functionality: (moderation, defcon, verification) p: 1 - high High Priority t: feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants