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

Bad Request: chat not found #308

Open
usadev1984 opened this issue Jun 18, 2024 · 1 comment
Open

Bad Request: chat not found #308

usadev1984 opened this issue Jun 18, 2024 · 1 comment

Comments

@usadev1984
Copy link

based on the documentation, my bot should be able to respond to a message without specifying the chat id if the message is in the same chat. however when i try something like the following code to respond to a message a user sent to the bot directly in dm:

const char * reply = "You're already in the chat.";
TgBot::ReplyParameters rp_params;
rp_params.allowSendingWithoutReply = true;
rp_params.messageId = ev->messageId;

bot->getApi().sendMessage(ev->chat->id, reply, nullptr, std::make_shared<TgBot::ReplyParameters>(rp_params));

i get Bad Request: chat not found. the only way around it is to provide the chat id. so for example the following works:

const char * reply = "You're already in the chat.";
TgBot::ReplyParameters rp_params;
rp_params.allowSendingWithoutReply = true;
rp_params.messageId = ev->messageId;
rp_params.chatId = ev->chat->id;

bot->getApi().sendMessage(ev->chat->id, reply, nullptr, std::make_shared<TgBot::ReplyParameters>(rp_params));

am i doing something wrong? im using the latest version of the library btw.

@uralm1
Copy link

uralm1 commented Nov 7, 2024

I confirm the problem. This is wrong api design (tgbot-cpp api, not a telegram). We can not skip optional fields in parameter structures.

Add to title: (Optional fields in Telegram parameter types classes is not optional).

I guess to use std::optional for that purpose. Or even better boost::optional, because it don't require cpp17 and integrates with boost:property_tree.

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