refactor: move common to internal and update public api

This commit is contained in:
2026-03-17 00:30:38 +01:00
parent 6ca04a9392
commit bb31304614
17 changed files with 284 additions and 272 deletions
+2 -1
View File
@@ -3,7 +3,8 @@
#include <stdio.h>
#include <string.h>
#include <tgbot.h>
#include <tgbot/methods.h>
#include <tgbot/tgbot.h>
bool run = true;
+8 -6
View File
@@ -4,7 +4,9 @@
#include <stdlib.h>
#include <string.h>
#include <tgbot.h>
#include <tgbot/methods.h>
#include <tgbot/tg_types.h>
#include <tgbot/tgbot.h>
#define WELCOME_MSG "Hi there! This bot is coded in C."
@@ -40,12 +42,12 @@ void sighandler(int signum) {
}
void parse_command(const tgbot_s *bot, const tgbot_update_s *update) {
tgbot_rc ret;
int ret;
if (strcmp("/start", update->text) == 0) {
ret = tgbot_send_message(bot, update->chat_id, WELCOME_MSG, "Markdown", keyboard);
if (ret != TGBOT_OK) {
if (ret != 0) {
fprintf(stderr, "Failed to send message\n");
}
@@ -54,7 +56,7 @@ void parse_command(const tgbot_s *bot, const tgbot_update_s *update) {
/* Echo the message */
ret = tgbot_send_message(bot, update->chat_id, update->text, "Markdown", NULL);
if (ret != TGBOT_OK) {
if (ret != 0) {
fprintf(stderr, "Failed to send message\n");
}
}
@@ -100,8 +102,8 @@ int main(void) {
/* Main loop */
while (run) {
tgbot_rc ret = tgbot_get_update(bot, &update, callback_handler);
if (ret != TGBOT_OK) {
int ret = tgbot_get_update(bot, &update, callback_handler);
if (ret != 0) {
fprintf(stderr, "tgbot_get_updates()\n");
continue;
}