summaryrefslogtreecommitdiff
path: root/samples
diff options
context:
space:
mode:
Diffstat (limited to 'samples')
-rw-r--r--samples/echobot-curl-client/src/main.cpp8
-rw-r--r--samples/echobot-webhook-server/src/main.cpp5
-rw-r--r--samples/echobot/src/main.cpp8
-rw-r--r--samples/inline-keyboard/src/main.cpp8
-rw-r--r--samples/photo/src/main.cpp8
5 files changed, 21 insertions, 16 deletions
diff --git a/samples/echobot-curl-client/src/main.cpp b/samples/echobot-curl-client/src/main.cpp
index 1f376a5..630dad8 100644
--- a/samples/echobot-curl-client/src/main.cpp
+++ b/samples/echobot-curl-client/src/main.cpp
@@ -8,8 +8,6 @@
using namespace std;
using namespace TgBot;
-bool sigintGot = false;
-
int main() {
string token(getenv("TOKEN"));
printf("Token: %s\n", token.c_str());
@@ -30,13 +28,15 @@ int main() {
signal(SIGINT, [](int s) {
printf("SIGINT got\n");
- sigintGot = true;
+ exit(0);
});
+
try {
printf("Bot username: %s\n", bot.getApi().getMe()->username.c_str());
+ bot.getApi().deleteWebhook();
TgLongPoll longPoll(bot);
- while (!sigintGot) {
+ while (true) {
printf("Long poll started\n");
longPoll.start();
}
diff --git a/samples/echobot-webhook-server/src/main.cpp b/samples/echobot-webhook-server/src/main.cpp
index 7b5776a..d51246d 100644
--- a/samples/echobot-webhook-server/src/main.cpp
+++ b/samples/echobot-webhook-server/src/main.cpp
@@ -26,6 +26,11 @@ int main() {
bot.getApi().sendMessage(message->chat->id, "Your message is: " + message->text);
});
+ signal(SIGINT, [](int s) {
+ printf("SIGINT got\n");
+ exit(0);
+ });
+
try {
printf("Bot username: %s\n", bot.getApi().getMe()->username.c_str());
diff --git a/samples/echobot/src/main.cpp b/samples/echobot/src/main.cpp
index 802d318..966ae6f 100644
--- a/samples/echobot/src/main.cpp
+++ b/samples/echobot/src/main.cpp
@@ -8,8 +8,6 @@
using namespace std;
using namespace TgBot;
-bool sigintGot = false;
-
int main() {
string token(getenv("TOKEN"));
printf("Token: %s\n", token.c_str());
@@ -28,13 +26,15 @@ int main() {
signal(SIGINT, [](int s) {
printf("SIGINT got\n");
- sigintGot = true;
+ exit(0);
});
+
try {
printf("Bot username: %s\n", bot.getApi().getMe()->username.c_str());
+ bot.getApi().deleteWebhook();
TgLongPoll longPoll(bot);
- while (!sigintGot) {
+ while (true) {
printf("Long poll started\n");
longPoll.start();
}
diff --git a/samples/inline-keyboard/src/main.cpp b/samples/inline-keyboard/src/main.cpp
index 0976989..70cf7c7 100644
--- a/samples/inline-keyboard/src/main.cpp
+++ b/samples/inline-keyboard/src/main.cpp
@@ -8,8 +8,6 @@
using namespace std;
using namespace TgBot;
-bool sigintGot = false;
-
int main() {
string token(getenv("TOKEN"));
printf("Token: %s\n", token.c_str());
@@ -41,13 +39,15 @@ int main() {
signal(SIGINT, [](int s) {
printf("SIGINT got\n");
- sigintGot = true;
+ exit(0);
});
+
try {
printf("Bot username: %s\n", bot.getApi().getMe()->username.c_str());
+ bot.getApi().deleteWebhook();
TgLongPoll longPoll(bot);
- while (!sigintGot) {
+ while (true) {
printf("Long poll started\n");
longPoll.start();
}
diff --git a/samples/photo/src/main.cpp b/samples/photo/src/main.cpp
index 03ca437..cca31f0 100644
--- a/samples/photo/src/main.cpp
+++ b/samples/photo/src/main.cpp
@@ -8,8 +8,6 @@
using namespace std;
using namespace TgBot;
-bool sigintGot = false;
-
int main() {
string token(getenv("TOKEN"));
printf("Token: %s\n", token.c_str());
@@ -27,13 +25,15 @@ int main() {
signal(SIGINT, [](int s) {
printf("SIGINT got\n");
- sigintGot = true;
+ exit(0);
});
+
try {
printf("Bot username: %s\n", bot.getApi().getMe()->username.c_str());
+ bot.getApi().deleteWebhook();
TgLongPoll longPoll(bot);
- while (!sigintGot) {
+ while (true) {
printf("Long poll started\n");
longPoll.start();
}