~luma_inhibitor/cables#67: 
Selectively notify upon activity from members

Implement staff notifications when particular users are active on the server.

Requirements:

  • An ON_MESSAGE event listener that compares the author to that of the elements in a configurable list of guild members
  • On match, craft a message including a mention of a configurable staff role, sending it to a configurable staff-only channel

Nice to have: Ability to set and compare the message volume to a configurable threshold of n messages over an interval within a single channel.

Use case: Staff may place a user on probation, or otherwise want to monitor them for conduct concerns. This would make it easier for moderators to fulfill their responsibilities in a timely manner, as it can often be difficult to keep up with the flow of chats.

Status
REPORTED
Submitter
~erin
Assigned to
Submitted
2 years ago
Updated
2 years ago
Labels
feature/enhancement moderation priority/high

~erin referenced this from #70 2 years ago

~erin 2 years ago

Draft of change committed to feature/user-watch @ ee2cf0f2. Still requires testing. Requested review from ~luma_inhibitor

~erin 2 years ago*

Started on testing. See this commit.

~erin 2 years ago

comments from eli:

if i add myself to the watch list and then make a post, it causes this error

File "/home/eli/code/cabling-bot/cabling_bot/events/message_watch_user.py", line 203, in handle_message
    watched, last_active = self._get(msg.guild.id, msg.author.id)
TypeError: cannot unpack non-iterable int object

the error disappears if i do bot reload and post again, though

i also added a logger statement to self._get() and it isn't showing, so i'm pretty sure the error is actually occurring in the previous line, which has this

        is_cached = self._get.has(msg.guild.id, msg.author.id)

steps to reproduce:

  1. watch list to verify you aren't already watched; if you are, remove yourself
  2. restart bot (clean cache)
  3. watch add
  4. make a post -- this will trigger the exception in the log -- bot won't send the watch message
  5. bot reload
  6. make a post -- no exception this time -- bot will send the watch message

there's also still the matter of not having permission gating on use of the commands that needs addressed.

~erin 2 years ago

Committed a bit of a change to catch the failure case of there being no watched user when _get is called. Also tried to fix the list deconstruction in the message handler, unsuccessfully.

When calling .watch list, this is returned:

  File "/usr/src/cables/cabling_bot/events/message_watch_user.py", line 212, in handle_message
    next_report = last_active + int(60 * 5)
TypeError: can only concatenate list (not "int") to list
...
  File "/usr/src/cables/cabling_bot/events/message_watch_user.py", line 206, in handle_message
    watched, *last_active = self._get(msg.guild.id, msg.author.id)
TypeError: cannot unpack non-iterable bool object

Which implies that the cursor is returning a result, but the method is returning false as if it didn't. This leads to last_active being an empty list, and the activity time comparison throwing the first exception. Also, the second exception implies that the list deconstruction is incorrect for what I'm trying to do.

I suppose a potential workaround here is to store the last active time in the DB, but that'd increase DB calls on message events, which I think is undesirable, even though it would be limited to every 5 minutes per active user.

Register here or Log in to comment, or comment via email.