G
G
ghostfromthepast2018-06-28 13:28:19
Python
ghostfromthepast, 2018-06-28 13:28:19

How to turn on and off part of the code in a telegram bot?

def sticker_recived(bot, update):
    admins = [admin.user.id for admin in bot.get_chat_administrators(chat_id=update.message.chat_id)]
    if update.message.from_user.id not in admins:
        bot.delete_message(chat_id=update.message.chat_id, message_id=update.message.message_id)

Here is an example code. I need a command (for example /on) to turn on deleting all stickers, and for another command (for example /off) to turn off the same deletion

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vyacheslav Boyko, 2018-06-28
@edkliff

I would hang a global flag (bool) that would change according to /on and /off , and put a condition on the code execution.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question