Answer the question
In order to leave comments, you need to log in
Question on telegram bot in python. How to implement a block of a person by a answered message and a special command?
The question is: is it possible to somehow implement a block of a person for a while, it happened not according to the message of this person, but according to the message answered by the admin with some text: the
person wrote a mate, I answer his message and write the word code for which the bot blocks the person on time???
Here is what I have
restricted_messages = ('цыц')
@bot.message_handler(func=lambda message: message.text and message.text.lower() in restricted_messages and message.chat.id == GROUP_ID)
def set_ro(message):
print(message.from_user.language_code)
bot.restrict_chat_member(message.chat.id, message.from_user.id, until_date=time()+300)
bot.send_message(message.chat.id, strings.get(get_language(message.from_user.language_code)).get("ro_msg"),
reply_to_message_id=message.message_id)
Answer the question
In order to leave comments, you need to log in
I solved it like this, but now it doesn't respond to the pip command and blocks everyone to whom I reply
restricted_messages = ('push')
def reply_validator(message):
if message.reply_to_message is None and restricted_messages:
return False
else:
return True
@bot .message_handler(func=reply_validator)
def set_ro(message):
print(message.from_user.language_code)
bot.restrict_chat_member(message.chat.id, message.reply_to_message.from_user.id, until_date=time()+300)
bot.send_message (message.chat.id, strings.get(get_language(message.from_user.language_code)).get("ro_msg"),
reply_to_message_id=message.message_id)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question