Answer the question
In order to leave comments, you need to log in
I created a bot, the code is below. writes an error, (error under the code) how can I fix the error?
here is the code
from telegram.ext import Updater, MessageHandler, Filters, CommandHandler
from telegram import ReplyKeyboardMarkup, ReplyKeyboardRemove
def start(bot, update):
update.message.reply_text('Hi
! You can use the hints below to get the information!',
reply_markup=markup)
def close_keyboard(bot, update):
update.message.reply_text('Ok', reply_markup=ReplyKeyboardRemove())
def echo(bot, update):
if update.message. text[-1] == '?':
update.message.reply_text('Of course you can ask!)
else:
update.message.reply_text('It's quite possible, who knows?')
def work(bot, update):
update.message.reply_text('Address: moscow showavparywashlprovylop')
def side job(bot, update):
update.message.reply_text ('lalalalalaalallaalalalalualalablabblablabla')
def feedback(bot, update):
update.message.reply_text('Telegram: @moneylssa')
def work_time(bot, update):
update.message.reply_text('Working time: 9:00 - 23: 00')
updater = Updater('1437844536:AAHQjUg2x6rDtIbcFPEQJ3LHNg0ljzD6eCo')
dp = updater.dispatcher
reply_keyboard =
markup = ReplyKeyboardMarkup(reply_keyboard, one_time_keyboard=False)
dp.add_handler(CommandHandler('start', start))
dp.add_handler(CommandHandler('close', close_keyboard))
dp.add_handler(CommandHandler('Work', work))
dp .add_handler(CommandHandler('Worktime', worktime))
dp.add_handler(CommandHandler('Feedback', feedback))
dp.add_handler(CommandHandler('Working time', work_time))
text_handler = MessageHandler(Filters.text, echo)
dp.add_handler(text_handler)
updater.start_polling()
updater.idle()
error:
Traceback (most recent call last):
File "D:\teleBOT\test.py", line 44, in
dp.add_handler(CommandHandler('Work', work))
File "C:\Users\Acer\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\telegram\ext\commandhandler.py", line 162, in __init__
raise ValueError ('Command is not a valid bot command')
ValueError: Command is not a valid bot command
Answer the question
In order to leave comments, you need to log in
He also pointed out that you did not do the right thing,
File "D:\teleBOT\telebot.py", line 47
dp.add_handler(CommandHandler('Hours of operation', hours of operation))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question