-
Notifications
You must be signed in to change notification settings - Fork 0
/
telegram.h
32 lines (26 loc) · 944 Bytes
/
telegram.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* ThePirat 2023 - Telegram helper */
#pragma once
#include <WiFiClientSecure.h>
#include <UniversalTelegramBot.h>
typedef void (*HandleMessage)(const String& text, const String& chat_id, const String& from, long message_id);
bool isMoreDataAvailable();
byte *getNextBuffer();
int getNextBufferLen();
class Telegram {
public:
Telegram(const String& token, const String& defaultChatId, long message_id, HandleMessage handleMessageCallback);
void ProcessInputMessages();
void SendMessage(const String& text);
void SendImage(uint8_t *buffer, unsigned long len);
void SendMessageWithReplyKeyboard(const String& text, const String& jsonKeyboard);
bool SetCommands(const String& commands);
private:
UniversalTelegramBot *bot;
WiFiClientSecure *client;
HandleMessage handleMessageCallback;
String _token;
String _defaultChatId;
String _lastChatId;
void handleNewMessages(int numNewMessages);
String getChatId();
};