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.
Create a cooldown dictionary where you can store people the bot has already pinged and the end of the cooldown. Ex: cooldows = {"JohnSmith#1234": 1597786825}.
Then when your bot tries to ping someone just check if they are in the dictionary. if they are check the epoch timestamp, if the time now is greater than the time listed, remove the user from the dictionary and ping him, if its not don't ping them. If they are not in the dictionary the bot can ping them
Is there a way to stop a Discord.py bot from doing a repeat action if it's been done in the past X seconds?