аватар question@mail.ru · 01.01.1970 03:00

How to give out a MUT for a minute if he spams the bot in Telegram?

I made my bot in Telegram with rather simple functions. The problem is that literally one person can put it with simple spam with one or more commands, and the error gives the error.

Here is the error: error - Telebot: "A recess to the telegram API WAS UNSUCCESSFUL. Error Code: 429 Description: Too Many Requests: Retry After 13 ""

I would like the user who, for example, send 10 messages for a short gap to receive a MUT for a minute and a message like "" Haha got caught Spammer "".

The bot is written on Python using Telebot (or Pytelegrambotapi), and the whole thing is launched on Heroku.

аватар answer@mail.ru · 01.01.1970 03:00

You can add a connection to the API to a telegram to a function, if an error in connection, you again call this function

   def   API  ():   try :  m =    experept :  API () api ()     

if you do not want to do it, you will have to use the database - store variables. This will help or Import Json or Import SQLite3 . If you do not want to store variables in the database, then keep them in Python using the python dictionary (dict). P.S in any case, you need Import Time . When processing a user message, you first check if there is it in the sheet, if you have, then write pass . mut = {"" id_user_1 "": {"" msg ":" 0, "min" ": 0}," Id_user_2 "" "" "" "" "" "" msg "": "min" ": 0} since the ID is a special key of the user, he will not be repeated, to tu to the user, do it mut [f "{id}" "] he will try to find it in the list.

   try :  mut [ f"  {id}  "" ] #is performed without error if the user is in the dictionary    experept :  mut [ f ""  {id}  "" ] = { "" msg "" :  0 ,  "" min ": Time.time ()} #when an error will register the user      

msg = the number of messages processed from the user mines =

Latest

Similar