TJ-Bot icon indicating copy to clipboard operation
TJ-Bot copied to clipboard

Delete last X messages from user for moderation

Open ankitsmt211 opened this issue 2 years ago • 6 comments

Problem: Sometimes you have a lot of messages from a user, that might not be appropriate or against the rules. Folks who write texts in smaller lengths, it can pile up to an "annoying no of deletes"

Possible solution: Introduction of new command "/delete user nNoOfMessages", which deletes the most n messages from given user.

ankitsmt211 avatar Oct 15 '23 23:10 ankitsmt211

In most cases that warrant mass-message-deletion, a (temporary) ban is warranted as well. Bans (including temp bans) already provide the functionality to purge messages.

But I still see how the command could be useful. Id advice to instead follow the UX of /ban and add options to purge messages based on time, not amount. For example:

  • last hour
  • last day
  • last 7 days

And to rename it to /purge, which is more idiomatic. In fact, there are some duplicates already: #17 #218 #238 #330 As you see, this command has been attempted thrice already 😆

Zabuzard avatar Oct 16 '23 07:10 Zabuzard

Interesting, I wonder what prevented the completion maybe too complex or scope not defined clearly?

Btw i was wondering about the implementation part, I have explored it a bit. I don't have exact implementation ideas atm but I think i might need to work with

image

I suppose I can get current instance of time and pull messages in bulk then filter based on a particular user and upto a certain interval . And finally do the delete operation. Thoughts?

ankitsmt211 avatar Oct 19 '23 07:10 ankitsmt211

The issue is that you have to retrieve hundreds if not thousands of messages from every channel, this command never got added because of rate limits.

There is no way to delete all messages sent in the last week, last hour already sounds overkill.

When implementing this, make sure to only retrieve from channels that the user has access to & can write to, otherwise you're wasting the limited history we can retrieve

Tais993 avatar Oct 19 '23 07:10 Tais993

Personally I'd say that the best implementation is to forward EVERY message to an SQL database, and then retrieve what messages have to be deleted from that.

But even then, deleting messages also got rate limited pretty harshly a year ago, I don't know how the current situation is. You can attempt this, but you really need to benchmark the rate limits before implementing.

Tais993 avatar Oct 19 '23 08:10 Tais993

Well in that case it might be unnecessary to delete messages upto a day or week , like zabu mentioned "deleting that many messages might require a ban instead". But i totally see how "upto 1 hour" mark can be useful.

ankitsmt211 avatar Oct 19 '23 08:10 ankitsmt211

This is what i have atm, as per suggestions i have decided to only to delete messages upto an hour.

  • Listener which writes all message records to DB when recieved
  • Routine that clears message records from DB if it's older than an hour or so
  • /purge command which has two options user and reason, reads ID's from DB, stores into a list.

For bulk deletion, this seems good.

image

Thoughts?

Edit: deleting messages from every channel seems pointless, since if someone is being a problem in more than one channel i don't think they're human and if they are they deserve a temp ban at that point. So this command will purge messages from the channel where it's used.

ankitsmt211 avatar Nov 03 '23 22:11 ankitsmt211