Add tgbot-cpp connector

This commit is contained in:
2026-07-15 12:02:55 +03:00
parent 070e90f538
commit 53f943515e
2 changed files with 121 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
#pragma once
#include <fstream>
#include <string>
#include <thread>
#include <memory>
#include "connectors/IConnector.h"
#include "external/tgbot-cpp/include/tgbot/tgbot.h"
#include "connectors/Types.h"
#include "core/inc/ThreadSafeQueue.h"
namespace MBFT
{
class TgbotCppConnector : public IConnector
{
private:
std::unique_ptr<TgBot::Bot> bot;
MBFT::ThreadSafeQueue<std::shared_ptr<MBFT::OutboundMessage>> sendQ;
MBFT::ThreadSafeQueue<std::shared_ptr<MBFT::InboundMessage>> recvQ;
std::thread inbound_thread;
std::thread outbound_thread;
void inbound_message_callback(TgBot::Message::Ptr message);
static void inbound_message_thread(TgBot::Bot& bot);
static void outbound_message_thread(TgBot::Bot& bot, MBFT::ThreadSafeQueue<std::shared_ptr<MBFT::OutboundMessage>>& q);
public:
TgbotCppConnector(void);
virtual std::shared_ptr<MBFT::InboundMessage> receive(void) override;
virtual void send(std::shared_ptr<MBFT::OutboundMessage>& msg) override;
};
}