How to add emoji to menu in telegram bot python?

Viewed 1027

I'm new in python and telegram bot developing, I'm trying to add emoji to bottom menu of the telegram bot, but I don't know how. Buttons in chat have already emoji, but bottom bot menu haven't. Thank you.

Example of code:

menu1 = telebot.types.InlineKeyboardMarkup([
    [InlineKeyboardButton(text=' Інформація', callback_data='info')],
    [InlineKeyboardButton(text=' Заборгованість', callback_data='arrears')],
    [InlineKeyboardButton(text=' Кабінет', callback_data='cabinet')],
    [InlineKeyboardButton(text=' Веб-сайт', url='')]])

Example of menu, that I've done:

enter image description here

2 Answers

you can add emoji in the same place where you add text

telegram.KeyboardButton(text="Hello ")

You can write down user_keyboard_markup() function and use it to display with each message you send. You can generate different functions to display different content depending on what users choose. You need just add reply_markup=... to your message.

my_markups_folder/markups.py:

def user_keyboard_markup():
    user_markup = ReplyKeyboardMarkup(True, True)
    button_site = KeyboardButton(text="Web site ")
    
    user_markup.row('/start', '/help', '/stop')
    user_markup.row('', '', '')
    user_markup.add(button_site)
    return user_markup

def my_other_keyboard_markup():
    return None

main.py:

...
from my_markups_folder.markups import user_keyboard_markup

...

@bot.message_handler(content_types=['text'])
def handle_text(message):
    if message.text == "show me keyboard markup":
        
        bot.send_message(message.from_user.id,
                         text=f"""
        *Motpheus:*
        Welcome back, Neo!
        """, parse_mode='markdown', reply_markup=user_keyboard_markup())

and you will see something like this:

...

enter image description here

Related