question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Solved] setGameScore & getGameHighScores has error if game starts from bot

See original GitHub issue

If a user starts a game from bot, when i want call getGameHighScores i should pass userId & chatId & messageId, but the error is:

Error: 400: Bad Request: chat not found

same as getGameHighScores the setGameScore pass the error:

Error: 400: Bad Request: wrong inline message identifier specified

there is no problem if I use inlineMessageId instead of chatId & messageId, but there is no inlineMessageId when game starts from bot. what should I do? where is the problem?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
sadracommented, Jun 2, 2017

I found the answer: if a user starts game from a group chat, you should pass just inline_message_id but if a user starts game from a bot, you should pass 3 items, id, chat_id and user_id you should ask which id? the answer is here, when a user starts the game, you cand get these 3 parameters from the gameQuery

{
  "id": "1122334455", //id
  "from": {
    "id": 6677889900, //user_id
    "first_name": "xxxxx",
    "last_name": "xxxxx",
    "username": "xxxxx",
    "language_code": "en"
  },
  "message": {
    "message_id": 123, //message_id
    "chat": {
      "id": 0099887766, //chat_id
      "first_name": "xxxxxx",
      "last_name": "xxxxxx",
      "username": "xxxxxxx",
      "type": "private"
    }
  },
  "chat_instance": "000000000000",
  "game_short_name": "xxxxxxxx"
}

so if you want get the high score:

bot.telegram.getGameHighScores(6677889900, '1122334455', 0099887766, 123)
    .then((score) =>{
        console.log('leader board: '+JSON.stringify(score))
    }).catch((err) =>{
        console.log('there is error: '+err)
    })

and if you want set score:

bot.telegram.setGameScore(6677889900, 21, '1122334455', 0099887766, 123)
    .then((score) =>{
        console.log('leader board: '+JSON.stringify(score))
    }).catch((err) =>{
        console.log('there is error: '+err)
    })
0reactions
sadracommented, Jun 3, 2017

Yes, that works with 'undefined' too!!! 😐

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to set game score using setGameScore in python ...
Used : bot.setGameScore (user_id = 5432131, score=76,inline_message_id=uygrtfghfxGKJB). I received these two(user_id,inline_message_id) ...
Read more >
setGameScore - aiogram 3.0.0b7 documentation
Returns an error, if the new score is not greater than the user's current score in the chat and force is False ....
Read more >
tgbotapi - Go Packages
Package tgbotapi has functions and types used for interacting with the Telegram Bot ... error); func (bot *BotAPI) GetGameHighScores(config ...
Read more >
Telegram Bot API
The Bot API is an HTTP-based interface created for developers keen on building ... In case of an unsuccessful request, 'ok' equals false...
Read more >
telebot-plugins - npm Package Health Analysis - Snyk
on(['/start', '/hello'], (msg) => msg.reply.text('Welcome!')); When sticker received, reply back: bot.on('sticker ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found