Answer the question
In order to leave comments, you need to log in
How to make a telegram bot respond to commands / start, etc. in python?
It didn’t work out to make the bot respond to the command, specifically, for a start, I wanted to program it to respond to the / start command, I used the following construction:
@bot.message_handler (command=['start']) def handler_start (message): bot.send_message (message.from_user. id, 'Hi, I'm a bot...') bot.polling (none stop=True)
Here, when you run the code, it just pops up a bunch of syntax errors, etc. How to fix?
Python 3.6.6, using the pyTelegramBot library
Whole script.
import telebot
import requests
from telebot import types
token = "token"
bot = telebot.TeleBot(token)
markup_menu = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=3)
btn_contant = types.KeyboardButton('Content')
btn_price = types.KeyboardButton('Price')
btn_Works = types.KeyboardButton('Works')
btn_call = types.KeyboardButton('Contact', request_location=True, request_contact=True)
markup_menu. add(btn_contant, btn_price, btn_Works, btn_call)
@bot.message_handler(commands=['start'])
def start(message):
bot.send_message(message.from_user.id, reply_markup=markup)
bot.polling(none_stop=True ) )
Answer the question
In order to leave comments, you need to log in
1. Decorate the code with the code tag.
2. Telepaths are on vacation, without a code, no one will specifically tell you where your syntax error is.
3. The syntax error is that none stop
you need to write through _.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question