skip to Main Content

when creating my own telegram bot I encountered an error

File "c:UsersКириллDesktoppython_bot — копияmain_part.py", line 7
bot.polling(none_stop=True, interval=0)
^
SyntaxError: invalid syntax

part with code:

bot = TeleBot('ToKeN')
@bot.message_handler(content_types=['text'])
bot.polling(none_stop=True, interval=0)

2

Answers


  1. Perhaps the @ in @bot.message_handler(content_types=['text']) is causing the error.

    Remove the @ and try again.

    Login or Signup to reply.
  2. after @… you should enter a method like this:

    @bot.message_handler(commands=['hello'])
    def handler(message):
        bot.reply_to(message,'hello!'
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search