Skip to content

Commit ce4773a

Browse files
committed
Issue witnessmenow#9: first take at answreCallbackQuery()
1 parent c01beb8 commit ce4773a

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/UniversalTelegramBot.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,3 +837,24 @@ bool UniversalTelegramBot::getFile(String& file_path, long& file_size, const Str
837837
}
838838
return false;
839839
}
840+
841+
bool UniversalTelegramBot::answerCallbackQuery(const String &query_id, const String &text, bool show_alert, const String &url, int cache_time) {
842+
String command = BOT_CMD("answerCallbackQuery?query_id=");
843+
command += query_id;
844+
command += F("&show_alert=");
845+
command += show_alert;
846+
command += F("&cache_time=");
847+
command += cache_time;
848+
if (!text.isEmpty()) {
849+
command += F("&text=");
850+
command += text;
851+
}
852+
if (!url.isEmpty()) {
853+
command += F("&url=");
854+
command += url;
855+
}
856+
String response = sendGetToTelegram(command); // receive reply from telegram.org
857+
bool answer = checkForOkResponse(response);
858+
closeClient();
859+
return answer;
860+
}

src/UniversalTelegramBot.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ class UniversalTelegramBot {
101101
bool disable_notification = false,
102102
int reply_to_message_id = 0, const String& keyboard = "");
103103

104+
bool answerCallbackQuery(const String &query_id,
105+
const String &text = "",
106+
bool show_alert = false,
107+
const String &url = "",
108+
int cache_time = 0);
109+
104110
bool setMyCommands(const String& commandArray);
105111

106112
String buildCommand(const String& cmd);

0 commit comments

Comments
 (0)