Add IConnector interface with corresponding types

This commit is contained in:
2026-07-15 12:00:40 +03:00
parent 50c81a8099
commit 0f5bafc295
4 changed files with 94 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
#include "connectors/BotToken.h"
#include <fstream>
#define TG_BOT_TOKEN_LENGTH 46
namespace MBFT
{
namespace BotToken
{
int get_token_length(void)
{
return TG_BOT_TOKEN_LENGTH;
}
bool load_token(char *buf)
{
buf[TG_BOT_TOKEN_LENGTH] = '\0';
std::ifstream f(".token");
if (f.is_open()) {
f.read(buf, TG_BOT_TOKEN_LENGTH);
f.close();
return true;
}
else
{
return false;
}
}
}
}
+10
View File
@@ -0,0 +1,10 @@
#pragma once
namespace MBFT
{
namespace BotToken
{
int get_token_length(void);
bool load_token(char *buf);
}
}
+13
View File
@@ -0,0 +1,13 @@
#pragma once
#include "connectors/Types.h"
namespace MBFT
{
class IConnector
{
public:
virtual std::shared_ptr<MBFT::InboundMessage> receive(void) = 0;
virtual void send(std::shared_ptr<MBFT::OutboundMessage>& msg) = 0;
};
}
+37
View File
@@ -0,0 +1,37 @@
#pragma once
#include <cstdint>
#include <memory>
namespace MBFT
{
struct User
{
std::int64_t id;
std::string firstName;
std::string lastName;
std::string username;
};
struct Chat
{
std::int64_t id;
std::string title;
};
struct InboundMessage
{
std::int32_t id;
std::int32_t thread_id;
std::uint32_t date;
std::string text;
std::shared_ptr<User> from;
std::shared_ptr<Chat> chat;
};
struct OutboundMessage
{
std::int64_t target_chat_id;
std::string text;
};
}