Skip to content

[BUG] InlineKeyboardButton with switch_inline_query='' doesn't work #1594

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

Closed
davidchoo12 opened this issue Nov 1, 2019 · 5 comments · Fixed by #1600
Closed

[BUG] InlineKeyboardButton with switch_inline_query='' doesn't work #1594

davidchoo12 opened this issue Nov 1, 2019 · 5 comments · Fixed by #1600
Assignees
Milestone

Comments

@davidchoo12
Copy link

Steps to reproduce

  1. Send a message with a inline keyboard button with switch_inline_query=''
inline_btn = InlineKeyboardButton('inline button', switch_inline_query='')
print(inline_btn)
markup = InlineKeyboardMarkup([[inline_btn]])
update.message.reply_text('message with inline button', reply_markup=markup)
  1. Output of the print statement:
    {'text': 'inline button'}
    along with error message: "Can't parse inline keyboard button: text buttons are unallowed in the inline keyboard"

Expected behaviour

The message should appear with the button as documented: "Can be empty, in which case just the bot’s username will be inserted."

Actual behaviour

Message and button doesn't appear and error is thrown

Configuration

Operating System:
Windows 10

Version of Python, python-telegram-bot & dependencies:

$ python -m telegram
python-telegram-bot 12.2.0
certifi 2019.09.11
future 0.18.1
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)]

Logs

{'text': 'inline button'}
WARNING - Update "..." caused error "Can't parse inline keyboard button: text buttons are unallowed in the inline keyboard"
@jh0ker
Copy link
Member

jh0ker commented Nov 1, 2019

Can confirm. Until fixed, you can use this workaround:

>>> from telegram import InlineKeyboardButton
>>> butt = InlineKeyboardButton('inline button', switch_inline_query='')
>>> butt.to_dict()
{'text': 'inline button'}
>>> butt.switch_inline_query = ''
>>> butt.to_dict()
{'text': 'inline button', 'switch_inline_query': ''}

@jh0ker jh0ker self-assigned this Nov 1, 2019
Copy link
Member

Eldinnie commented Nov 1, 2019

@davidchoo12 Good catch thanks

@Bibo-Joshi
Copy link
Member

Will hopefully be closed by #1600

Copy link
Member

jh0ker commented Nov 7, 2019

@Bibo-Joshi We should add test cases for this

@Poolitzer
Copy link
Member

Will hopefully be closed by #1600

Can confirm it will be closed

@github-actions github-actions bot locked and limited conversation to collaborators Aug 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants