I’m using pyrogram to send a html 5 game to my friends. I create a game call "popspike" from @botfather and this is the link of my html 5 game. Image below is the game example without inline button. The button is auto generated by telegram and the button is not works to launch my html 5 game.
According to discussion in stackoverflow and the documentation manual provided, we need to use callback_query.answer(url="your website")
to open my html 5 game (popspike), so I create an inline button to callbakc the query data.
@app.on_message(filters.command("popspike"))
async def start_command(client, message): #send game to user & inline button send callback query
await message.reply_game('popspike'
,reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("Play popspike",callback_data='test',callback_game=CallbackGame())]])) #reply markup is the error
@app.on_callback_query()
async def openquery(client, callback_query): #show text "hello" and open my html 5 game through `url` para
await callback_query.answer("Hello", show_alert=True, url='https://lmjaedentai.github.io/popspike')
But I met this error when I want to call this command /popspike
to send my game to user, so I failed to send the game to user.
Telegram says: [400 REPLY_MARKUP_GAME_EMPTY] - The provided reply markup for the game is empty (caused by "messages.SendMedia")
Traceback (most recent call last):
File "D:Desktopcodingdiscordpyenvlibsite-packagespyrogramdispatcher.py", line 222, in handler_worker
await handler.callback(self.client, *args)
File "D:Desktopcodingdiscordpyenvlibsite-packagespyromodlistenlisten.py", line 93, in resolve_listener
await self.user_callback(client, message, *args)
File "d:Desktopcodingdiscordpytelegrammain.py", line 118, in start_command
await message.reply_game('popspike',reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("Play poxpspike",callback_data='test',callback_game=CallbackGame())]]))
File "D:Desktopcodingdiscordpyenvlibsite-packagespyrogramtypesmessages_and_mediamessage.py", line 1633, in reply_game
return await self._client.send_game(
File "D:Desktopcodingdiscordpyenvlibsite-packagespyrogrammethodsbotssend_game.py", line 74, in send_game
r = await self.send(
File "D:Desktopcodingdiscordpyenvlibsite-packagespyrogrammethodsadvancedsend.py", line 77, in send
r = await self.session.send(
File "D:Desktopcodingdiscordpyenvlibsite-packagespyrogramsessionsession.py", line 362, in send
return await self._send(data, timeout=timeout)
File "D:Desktopcodingdiscordpyenvlibsite-packagespyrogramsessionsession.py", line 332, in _send
RPCError.raise_it(result, type(data))
File "D:Desktopcodingdiscordpyenvlibsite-packagespyrogramerrorsrpc_error.py", line 91, in raise_it
raise getattr(
pyrogram.errors.exceptions.bad_request_400.ReplyMarkupGameEmpty: Telegram says: [400 REPLY_MARKUP_GAME_EMPTY] - The provided reply markup for the game is empty (caused by "messages.SendMedia")
I do provide InlineKeyboardButton
in send_game
but why Telegram says "reply markup for the game is empty" ?
I apologizes for the long question since I afraid you cant understand I want to ask.
Hope you can help me. Thank you. 🙏🏻
2
Answers
As per the docs of
InlineKeyboardButton
So try removing
callback_data='test'
from the construction of the button.Edit: More precisely,
send_game
will automatically add such a button to your message. You only need to manually attach a keyboard, if you want more than 1 button to be appended. In this case, the first button must be the one withcallback_game=CallbackGame()
.Note that for this button,
callback_data
is not needed to be able to parse the resultingCallbackQuery
. This is becauseCallbackQuery.data
will not be present, butCallbackQuery.game_short_name
will.The corresponding explanations from the official Telegram docs:
Do this on the second paragraph:
Give the argument
filters.regex('test')
inside@app.on_callback_query()