Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot add buttons to keyboard with emoji as bytes #265

Closed
Yolley opened this issue Dec 6, 2016 · 4 comments
Closed

cannot add buttons to keyboard with emoji as bytes #265

Yolley opened this issue Dec 6, 2016 · 4 comments

Comments

@Yolley
Copy link
Contributor

Yolley commented Dec 6, 2016

Please answer these questions before submitting your issue. Thanks!

  1. What version of pyTelegramBotAPI are you using?
    2.2.3

  2. What version of python are you using?
    3.5.2

I have a message_handler:

@bot.message_handler(commands=['vote'])
def voter(message):
	markup = telebot.types.ReplyKeyboardMarkup(one_time_keyboard=True, selective=True)
	markup.add(b'\xF0\x9F\x94\xA5')
	markup.add(b'\xF0\x9F\x93\xB7')
	bot.reply_to(message, 'Choose', reply_markup=markup)

Which tries to make a custom keyboard with emoji's. I represent them as bytes and it works well, when i just send them with send_message.
But when i try to add a button to keyboard, i get an error:

File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/telebot/types.py", line 610, in add
    row.append(button.to_dic())
AttributeError: 'bytes' object has no attribute 'to_dic'

I think, it's a bug, cuz if i add to 'add' function something like this:

            elif isinstance(button, bytes):
                row.append({'text': button.decode('utf-8')})

It works well, and buttons add successfully to keyboard.
Is it going to be fixed?

Thank you!

@Yolley Yolley changed the title cannot add bot buttons with emoji as bytes cannot add buttons to keyboard with emoji as bytes Dec 6, 2016
@MasterGroosha
Copy link
Contributor

Have you tried copy-pasting emojis into your IDE directly? Works fine for me, since emoji = Unicode character

@Yolley
Copy link
Contributor Author

Yolley commented Dec 6, 2016

Actually this idea didn't come to my mind. Tried it, and yes, it worked, thank you!

Before trying to represent them as bytes, I tried to past emoji's with unicode, but i didn't copy the emoji itself, i copied the code from there http://apps.timwhitlock.info/emoji/tables/unicode, and every emoji looked like this
emoji
So that's why i thought, that i should try to past them as bytes.

@MasterGroosha
Copy link
Contributor

Is your problem solved?

@Yolley
Copy link
Contributor Author

Yolley commented Dec 13, 2016

Yes, thank you!

@Yolley Yolley closed this as completed Dec 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants