diff --git a/connectors/BotToken.cpp b/connectors/BotToken.cpp new file mode 100644 index 0000000..b2fe95d --- /dev/null +++ b/connectors/BotToken.cpp @@ -0,0 +1,34 @@ +#include "connectors/BotToken.h" + +#include + +#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; + } + } + } +} diff --git a/connectors/BotToken.h b/connectors/BotToken.h new file mode 100644 index 0000000..21b05c7 --- /dev/null +++ b/connectors/BotToken.h @@ -0,0 +1,10 @@ +#pragma once + +namespace MBFT +{ + namespace BotToken + { + int get_token_length(void); + bool load_token(char *buf); + } +} diff --git a/connectors/IConnector.h b/connectors/IConnector.h new file mode 100644 index 0000000..e402bd6 --- /dev/null +++ b/connectors/IConnector.h @@ -0,0 +1,13 @@ +#pragma once + +#include "connectors/Types.h" + +namespace MBFT +{ + class IConnector + { + public: + virtual std::shared_ptr receive(void) = 0; + virtual void send(std::shared_ptr& msg) = 0; + }; +} diff --git a/connectors/Types.h b/connectors/Types.h new file mode 100644 index 0000000..4a69c3d --- /dev/null +++ b/connectors/Types.h @@ -0,0 +1,37 @@ +#pragma once + +#include +#include + +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 from; + std::shared_ptr chat; + }; + + struct OutboundMessage + { + std::int64_t target_chat_id; + std::string text; + }; +}