35 lines
797 B
C++
35 lines
797 B
C++
#pragma once
|
|
#include <Arduino.h>
|
|
#include <UniversalTelegramBot.h>
|
|
#include <WiFiClientSecure.h>
|
|
|
|
struct TelegramCommand
|
|
{
|
|
const String command;
|
|
String (*const functionPointer) (const String arguments);
|
|
};
|
|
|
|
class Telegram
|
|
{
|
|
private:
|
|
static const char *BOT_TOKEN;
|
|
static const unsigned long BOT_MTBS; // mean time between scan messages
|
|
|
|
|
|
unsigned long bot_lasttime; // last time messages' scan has been done
|
|
WiFiClientSecure &secured_client;
|
|
UniversalTelegramBot bot;
|
|
TelegramCommand *cmdList;
|
|
uint32_t cmdListCount;
|
|
|
|
void handleNewMessages(int numNewMessages);
|
|
|
|
public:
|
|
Telegram(WiFiClientSecure &sec_client, TelegramCommand commandList[], uint32_t commandListCount);
|
|
~Telegram();
|
|
|
|
void init();
|
|
void cyclic(unsigned long now);
|
|
};
|
|
|