I currently have a bot that pings people if certain criteria are met. The issue is that the bot will ping spam if the content is repeated. For example, say user JohnSmith#1234 says "ping me if someone says 'apple' or 'apples' in the chat.' It'll do so. However, say there are 4 messages in quick succession:
User1: "Hey, do you like apples?"
User2: "Yeah, I like apples"
User1: "What's your favorite kind of apple?"
User2: "I don't really have a favorite apple, but I like Granny Smith"
then the bot will say:
@JohnSmith#1234 for "apple"
@JohnSmith#1234 for "apple"
@JohnSmith#1234 for "apple"
@JohnSmith#1234 for "apple"
because "apple" was mentioned 4 times. Is there a way to tell the bot "if you pinged JohnSmith#1234 in the last 10 seconds, don't ping him again?" I basically want an action to not execute if it's been done recently.
Edit:
While the answers shown seem to work for just 1 user, they don't seem to work for multiple. The answers will accommodate JohnSmith#1234 just fine, but as of now, it'll render the bot useless until JohnSmith#1234's delay is done.
I'm not sure how to tell the bot "keep doing what you're doing, but run the delay loop on the side." Here's what the bot is currently doing, continuing off of the example I provided previously:
1: Say @JohnSmith#1234 for 'apple'
2: Puts John Smith into a waiting dictionary until 10 seconds is up. (Note: the bot won't do anything else but wait. This is bad because it should ping users besides John Smith).
3: If those 10 seconds are up, it'll ping John Smith again. Otherwise, it'll keep doing stuff for other users.