Skip to content

Commit

Permalink
Update samples to API 7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
llnulldisk committed Apr 20, 2024
1 parent 261f27b commit 5154dab
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions samples/inline-keyboard/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ int main() {
keyboard->inlineKeyboard.push_back(row0);

bot.getEvents().onCommand("start", [&bot, &keyboard](Message::Ptr message) {
bot.getApi().sendMessage(message->chat->id, "Hi!", false, 0, keyboard);
bot.getApi().sendMessage(message->chat->id, "Hi!", nullptr, nullptr, keyboard);
});
bot.getEvents().onCommand("check", [&bot, &keyboard](Message::Ptr message) {
string response = "ok";
bot.getApi().sendMessage(message->chat->id, response, false, 0, keyboard, "Markdown");
bot.getApi().sendMessage(message->chat->id, response, nullptr, nullptr, keyboard, "Markdown");
});
bot.getEvents().onCallbackQuery([&bot, &keyboard](CallbackQuery::Ptr query) {
if (StringTools::startsWith(query->data, "check")) {
string response = "ok";
bot.getApi().sendMessage(query->message->chat->id, response, false, 0, keyboard, "Markdown");
bot.getApi().sendMessage(query->message->chat->id, response, nullptr, nullptr, keyboard, "Markdown");
}
});

Expand Down
7 changes: 4 additions & 3 deletions samples/receive-file/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ int main() {
bot.getEvents().onAnyMessage([&bot](Message::Ptr message) {
printf("User wrote %s\n", message->text.c_str());

File::Ptr file = bot.getApi().getFile(message->document->fileId);
string fileContent = bot.getApi().downloadFile(file->filePath);

if (StringTools::startsWith(message->text, "/start")) {
return;
}

File::Ptr file = bot.getApi().getFile(message->document->fileId);
string fileContent = bot.getApi().downloadFile(file->filePath);

bot.getApi().sendMessage(message->chat->id, "Your file content: " + fileContent);
});

Expand Down
4 changes: 2 additions & 2 deletions samples/reply-keyboard/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ int main() {
}, keyboardWithLayout);

bot.getEvents().onCommand("start", [&bot, &keyboardOneCol](Message::Ptr message) {
bot.getApi().sendMessage(message->chat->id, "/start for one column keyboard\n/layout for a more complex keyboard", false, 0, keyboardOneCol);
bot.getApi().sendMessage(message->chat->id, "/start for one column keyboard\n/layout for a more complex keyboard", nullptr, nullptr, keyboardOneCol);
});
bot.getEvents().onCommand("layout", [&bot, &keyboardWithLayout](Message::Ptr message) {
bot.getApi().sendMessage(message->chat->id, "/start for one column keyboard\n/layout for a more complex keyboard", false, 0, keyboardWithLayout);
bot.getApi().sendMessage(message->chat->id, "/start for one column keyboard\n/layout for a more complex keyboard", nullptr, nullptr, keyboardWithLayout);
});
bot.getEvents().onAnyMessage([&bot](Message::Ptr message) {
printf("User wrote %s\n", message->text.c_str());
Expand Down

0 comments on commit 5154dab

Please sign in to comment.