Answer the question
In order to leave comments, you need to log in
Code not working how to fix?
There is a code that does not work correctly, namely, for some reason, it reacts to all the words that I wrote to the bot and not only to those that are written in the code
@bot.message_handler(func=lambda message: words)
def buan(message):
from time import time
file = open('data.txt','r')
TIB = file.read()
bot.restrict_chat_member(message.chat.id, message.from_user.id, until_date=time()+(int(TIB)))
Answer the question
In order to leave comments, you need to log in
The decorator is wrong.
@bot.message_handler(func=lambda m: True)
def buan(message):
if message.text not in words:
return
from time import time
file = open('data.txt','r')
TIB = file.read()
bot.restrict_chat_member(message.chat.id, message.from_user.id, until_date=time()+(int(TIB)))
Why did you decide to make bots without even knowing the basics of programming? Oh, the youth has gone. Read the documentation https://github.com/eternnoir/pyTelegramBotAPI , or better yet, read about lambda functions first. I think there is nothing more to explain, programmers in most cases are not psychics, so it is always necessary to read the documentation first.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question