feat: add Telegram bot with long polling and message splitting
Direct HTTPS long polling against Telegram Bot API (getUpdates), JSON parsing with cJSON, auto-split at 4096 chars, Markdown with plain-text fallback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
27
main/telegram/telegram_bot.h
Normal file
27
main/telegram/telegram_bot.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include "esp_err.h"
|
||||
|
||||
/**
|
||||
* Initialize the Telegram bot.
|
||||
* Reads bot token from NVS.
|
||||
*/
|
||||
esp_err_t telegram_bot_init(void);
|
||||
|
||||
/**
|
||||
* Start the Telegram polling task (long polling on Core 0).
|
||||
*/
|
||||
esp_err_t telegram_bot_start(void);
|
||||
|
||||
/**
|
||||
* Send a text message to a Telegram chat.
|
||||
* Automatically splits messages longer than 4096 chars.
|
||||
* @param chat_id Telegram chat ID (numeric string)
|
||||
* @param text Message text (supports Markdown)
|
||||
*/
|
||||
esp_err_t telegram_send_message(const char *chat_id, const char *text);
|
||||
|
||||
/**
|
||||
* Save the Telegram bot token to NVS.
|
||||
*/
|
||||
esp_err_t telegram_set_token(const char *token);
|
||||
Reference in New Issue
Block a user