feat(tgbot-back): start to develop back
Implemented fetchUserTitlesAsync func and embedded it in the code of the front in the trial mode. It needs to be restructured
This commit is contained in:
parent
4ca8b19adb
commit
847aec7bdd
9 changed files with 190 additions and 13 deletions
|
|
@ -7,7 +7,7 @@ public:
|
|||
static TgBot::InlineKeyboardMarkup::Ptr createMainMenu();
|
||||
|
||||
/// Create keyboard for My_Titles
|
||||
static TgBot::InlineKeyboardMarkup::Ptr createMyTitles(std::vector<Title> titles);
|
||||
static TgBot::InlineKeyboardMarkup::Ptr createMyTitles(std::vector<BotStructs::Title> titles);
|
||||
|
||||
/// Create keyboard for sendError
|
||||
static TgBot::InlineKeyboardMarkup::Ptr createError(const std::string& errorCallback);
|
||||
|
|
|
|||
|
|
@ -39,5 +39,6 @@ namespace BotConstants {
|
|||
const std::string MAIN_MENU = "Вас приветствует nyanimedb бот:)\nЧего будем делать?";
|
||||
const std::string SAD_ERROR = "У нас что-то случилось:(\nМы обязательно скоро исправимся";
|
||||
const std::string AUTH_ERROR = "Проблемы с авторизацией, попробуйте авторизоваться повторно";
|
||||
const std::string SERVER_ERROR = "Не удалось загрузить данные. Попробуйте позже.";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include <string>
|
||||
#include <structs.hpp>
|
||||
#include <unordered_map>
|
||||
#include "BotToServer.hpp"
|
||||
|
||||
/// @brief Структура возвращаемого значения класса BotHandlers для изменения текущего сообщения
|
||||
struct HandlerResult {
|
||||
|
|
@ -58,6 +59,7 @@ public:
|
|||
private:
|
||||
TgBot::Api botApi;
|
||||
std::unordered_map<int64_t, UserContext> userContexts;
|
||||
BotToServer server_;
|
||||
|
||||
void handleNavigation(TgBot::CallbackQuery::Ptr query, UserContext& ctx);
|
||||
|
||||
|
|
@ -104,7 +106,7 @@ private:
|
|||
/// @brief Отрисовка текущего экрана (соотв. контексту)
|
||||
/// @param ctx - текущий контекст
|
||||
/// @return HandlerResult для нового состояния сообщения
|
||||
HandlerResult renderCurrent(const UserContext& ctx);
|
||||
HandlerResult renderCurrent(TgBot::CallbackQuery::Ptr query, const UserContext& ctx);
|
||||
|
||||
/// @brief Логика переходов между контекстами (навигация на следующий шаг)
|
||||
/// @param query - запрос
|
||||
|
|
@ -120,4 +122,7 @@ private:
|
|||
/// @brief Посылает интерфейс обработки ошибки на callback запрос
|
||||
/// @param query запрос
|
||||
void sendError(TgBot::CallbackQuery::Ptr query, const std::string& errText);
|
||||
|
||||
// Форматирование для отображения в сообщении
|
||||
std::string formatTitlesList(const std::vector<BotStructs::Title>& titles);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
namespace BotStructs {
|
||||
struct Title {
|
||||
int64_t id;
|
||||
std::string name;
|
||||
std::string description;
|
||||
int64_t num;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue