P
P
Poohovin2018-01-30 15:53:24
Bots
Poohovin, 2018-01-30 15:53:24

Error starting Bot for Telegram?

On MacOs, the bot is launched on the command line, but on Windows it gives an error
C:\Users\Desktop\TelegramBot>python robot.py
Traceback (most recent call last):
File "robot.py", line 2, in
import telebot
File "C :\Users\AppData\Local\Programs\Python\Python37\lib\site-packag
es\telebot\__init__.py", line 1291
@util.async()
^
SyntaxError: invalid syntax
Here's the code itself:
# code: utf8
import telebot
TOKEN = '4825654808:AAHD4dlwF-LgMvdyfefefefefefef'
bot = telebot.TeleBot (TOKEN)
@bot.message_handler(commands=['start'])
def start(message):
sent = bot.send_message(message.chat.id, 'Hello! What's your name?')
bot.register_next_step_handler(sent, hello)
def hello(message):
bot.send_message(message.chat.id, 'Hi, {name }.Good to see you.'.format(name=message.text))
name = bot.send_message(message.chat.id, '{name}, write your question'.format(name=message.text))
bot. register_next_step_handler(name, next)
def next(message):
bot.send_message(message.chat.id, 'Thank you {} for your question! Your question will be answered soon'.format(last_chat_name))
if __name__ == '__main__' :
bot.polling(none_stop=True)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
enabl3, 2018-01-30
@Poohovin

Try adding:
instead of yours at the beginning:
# code: utf8

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question