I'm trying to write a Telegram bot to help a friend with his online buisness.
I'm trying to make an interactive menu, but if I try to use an emoji as a prefix the @bot.message_handler
doesn't read the user input, resulting in the menu not updating.
Working code (with "/" as command prefix):
@bot.message_handler(commands=["Menu"])
def startMenu(msg):
#########-START MENU-#########
markup = keyboard = types.ReplyKeyboardMarkup(row_width=1, resize_keyboard=True, one_time_keyboard=True)
btnHelp = types.KeyboardButton("/Help")
##############################
markup.add(btnHelp)
bot.send_message(msg.chat.id, text="Need help?"
, reply_markup=markup)
@bot.message_handler(commands=["Help"])
def helpMenu(msg):
markup = keyboard = types.ReplyKeyboardMarkup(row_width=1, resize_keyboard=True, one_time_keyboard=True)
btnBack = types.KeyboardButton("/Menu")
markup.add(btnBack)
bot.send_message(msg.chat.id, text="Test Help"
, reply_markup=markup)
Faulty code (with UNICODE emoji as prefix):
@bot.message_handler(commands=["Menu"])
def startMenu(msg):
#########-START MENU-#########
markup = keyboard = types.ReplyKeyboardMarkup(row_width=1, resize_keyboard=True, one_time_keyboard=True)
btnHelp = types.KeyboardButton("\U0001F60Help")
##############################
markup.add(btnHelp)
bot.send_message(msg.chat.id, text="Need help?"
, reply_markup=markup)
@bot.message_handler(commands=["\U0001F60Help"])
def helpMenu(msg):
markup = keyboard = types.ReplyKeyboardMarkup(row_width=1, resize_keyboard=True, one_time_keyboard=True)
btnBack = types.KeyboardButton("/Menu")
markup.add(btnBack)
bot.send_message(msg.chat.id, text="Test Help"
, reply_markup=markup)