skip to Main Content

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


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

    telegram.KeyboardButton(text="Hello ๐Ÿ‘‹๐Ÿป")
    
    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search