tictactoebot/include/bot.h

33 lines
774 B
C++

#pragma once
#include <map>
#include "config.h"
#include "TAPIManager.h"
#include "TAPIMarkup.h"
#include "game.h"
class Bot {
public:
Bot(TelegramAPI::Manager* tapi, Conf& conf);
~Bot();
bool handleStart(TelegramAPI::Manager* api, const TelegramAPI::Message& msg);
bool handleMessage(TelegramAPI::Manager* api, TelegramAPI::Message& msg);
bool handleCallback(TelegramAPI::Manager* api, TelegramAPI::CallbackQuery& clbq);
void stop();
private:
TelegramAPI::Manager* tapi;
Conf& conf;
void updateGame(int64_t chatid, uint64_t msgid, const Game* g);
TelegramAPI::InlineKeyboard gameToKeyboard(const Game*) const;
std::string gameToMessage(const Game*) const;
// maps <chatid, messageid> -> gameptr
std::map<std::pair<int64_t, uint64_t>, Game*> games;
};