S
S
Soneiko2021-04-30 11:30:03
Bots
Soneiko, 2021-04-30 11:30:03

How to make a cooldown for an event?

I make in my bot the so-called reputation parameter in the form of emoji. It is given by other people in two ways. One way is to add an emoji reaction to a user's message, and the second is to simply mention the person in the message with this emoji. But I need to have a cooldown for issuing reputation to the same person.
For example:

User A gave reputation to User B
User A gave reputation to user C
User A gave reputation to user D
User A gave reputation to User B

If reputation is given to others, then everything is fine. But if given to the same person, it needs a 5 minute cooldown. However, this should only work for User A, if the reputation is given by another, it should be added.

I'm only interested in the cooldown system itself. I'll deal with the rest myself.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
_
_, 2021-04-30
@mrxor

The key in the cache is user_a:user_b with the required TTL
Or take a ready-made solution, such as limits

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question