W
W
WLC2HELL2021-01-04 19:56:55
Python
WLC2HELL, 2021-01-04 19:56:55

I created a telegram bot, it gives an error (see below), what should I do?

THE CODE:

from telegram.ext import Updater, MessageHandler, Filters, CommandHandler
from telegram import ReplyKeyboardMarkup, ReplyKeyboardRemove

def start(bot, update):
    update.message.reply_text('Привет! Я информационный бот компании "бла бла бла".\n'
                              'Для получения информации можете воспользоваться подсказками ниже!',
                              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('Конечно можно спросить! Только я культурно промолчу...')
    else:
        update.message.reply_text('Вполне возможно, кто ж знает?')
    
def работа(bot, update):
    update.message.reply_text('Адрес: москва')

def подработка(bot, update):
    update.message.reply_text('лалалалалалаалаллаалалалалюалюалаблаблаблабла')

def обратная_связь(bot, update):
    update.message.reply_text('Телеграм: @(засекречено)')

def время_работы(bot, update):
    update.message.reply_text('Время работы: 9:00 - 23:00')


updater = Updater('засекречено')

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('Работа', работа))
dp.add_handler(CommandHandler('Подработка', подработка))
dp.add_handler(CommandHandler('Обратная связь', обратная связь))
dp.add_handler(CommandHandler('Время работы', время работы))

text_handler = MessageHandler(Filters.text, echo)
dp.add_handler(text_handler)

updater.start_polling()

updater.idle()


Traceback (most recent call last):
File "D:\teleBOT\telebot.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

1 answer(s)
O
Oleg, 2021-01-04
@402d

https://core.telegram.org/bots#commands
A command must always start with the '/' symbol and may not be longer than 32 characters. Commands can use latin letters, numbers and underscores.
Russian words like yours as commands are not supported
if you really need to. Then these are no longer commands, but an independent analysis of the message itself from the user for the right words

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question