Answer the question
In order to leave comments, you need to log in
An error in the code when trying to restrict access to the bot?
Help with solving the error. I decided to restrict access to the telegram bot like this:
import telebot
bot = telebot.TeleBot('мой ключ бота')
@bot.message_handler(commands=['start'])
def checkuserCommand(bot,update):
if update.message.from_user.id == "мой айди телеграмма":
if update.message.text == "/start":
def start_message(message):
bot.send_message(message.chat.id, 'Привет!')
bot.polling(none_stop=True, interval=0)
Answer the question
In order to leave comments, you need to log in
Keep the correct code!
import telebot
bot = telebot.TeleBot('мой ключ бота')
@bot.message_handler(commands=['start'])
def start(message):
if message.from_user.id == "мой айди телеграмма":
bot.send_message(message.chat.id, 'Привет!')
bot.polling(none_stop=True, interval=0)
Why do you have bot in function parameters when message should be there? And what do you have for update in the parameters? The function has only 1 argument according to the documentation
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question