python-discord / bot

The community bot for the Python Discord community
https://pythondiscord.com
MIT License
1.34k stars 665 forks source link

Keyword Alerts #3153

Open HassanAbouelela opened 1 year ago

HassanAbouelela commented 1 year ago

What feature are you proposing?

Send a DM to members when the bot detects a certain keyword in the incoming messages.

What is your justification for the proposed feature?

This was something that was suggested before, but I was against it previously for the following reasons:

  1. It is easy to abuse this system to stalk/follow people. It's not something we should enable.
  2. It is possible to create alerts which fire on way too many messages (for instance just watching the letter e), which can create issues with ratelimits.

The ratelimits thing is probably not an issue, we have a pretty high cap. Both of these issues were addressed by the following suggestion in community meta:

I thought about this for a while and I believe most concerns would be alleviated if we hard-coded a list of keywords that could be monitored, and limited the monitoring to code blocks.

I think that's a valid compromise that could enable a nice feature. I still do have some reservations about the number of alerts, and would like to trial this feature out without sending alerts (just log statistics), but we can hash out implementation details later.

Preocts commented 1 year ago

I'm genuinely curious to see an implementation of it and learn about who used this and how often.

The ratelimits thing is probably not an issue, we have a pretty high cap.

I play devil's eggvocate here when I ask: What measure can be put in place to cap this limit? Imagining a doom's day situation of hundreds of accounts joining, subscribing, and proceeding to trigger the limited keyword list.

swfarnsworth commented 1 year ago

We would need a way for people to automatically become unsubscribed if they go inactive, so that the bot doesn't waste API calls sending DMs to abandoned accounts. I think the easiest way would be for subscriptions to automatically unsubscribe after a fixed duration (say, a month), and people who still want to subscribe to that keyword can run the command again. (This would also have the effect of passively unsubscribing people from keywords that they've lost interest in, but for some reason couldn't be bothered to unsub from.)

jb3 commented 3 weeks ago

Transferred issue to bot pending implementation.

We likely don't need to worry about ratelimits, abandoned accounts get purged by Discord after a period of time and as mentioned our ratelimits are high enough for us not to worry.

We should not overengineer this and instead should add the ability to observe the feature and address ratelimits down the line should they become a problem (which is highly unlikely)