auto join game
This commit is contained in:
parent
188db932fb
commit
8a69fdc81f
15
src/bot.cpp
15
src/bot.cpp
|
@ -2,6 +2,11 @@
|
|||
|
||||
#include <sstream>
|
||||
|
||||
static Game::UserInfo userToUserInfo(const TelegramAPI::User& u) {
|
||||
// + (u.last_name.empty() ? "" : " " + u.last_name) // problems with spaces and unicode in last name
|
||||
return {u.id, u.first_name, u.username};
|
||||
}
|
||||
|
||||
Bot::Bot(TelegramAPI::Manager* tapi, Conf& conf) : tapi(tapi), conf(conf) {}
|
||||
|
||||
Bot::~Bot() {}
|
||||
|
@ -15,6 +20,11 @@ bool Bot::handleStart(TelegramAPI::Manager* api, const TelegramAPI::Message& msg
|
|||
// create a empty game
|
||||
Game g;
|
||||
|
||||
// @GroupAnonymousBot
|
||||
if(msg.from.id != 1087968824 && !msg.from.is_bot) {
|
||||
g.addPlayer(userToUserInfo(msg.from));
|
||||
}
|
||||
|
||||
std::vector<TelegramAPI::MessageEntity> entities;
|
||||
const std::string text = gameToMessage(g, entities);
|
||||
auto sendmsg = api->sendMessage(msg.chat.id, text, gameToKeyboard(g), entities);
|
||||
|
@ -26,11 +36,6 @@ bool Bot::handleMessage(TelegramAPI::Manager* api, TelegramAPI::Message& msg) {
|
|||
return true;
|
||||
}
|
||||
|
||||
static Game::UserInfo userToUserInfo(const TelegramAPI::User& u) {
|
||||
// + (u.last_name.empty() ? "" : " " + u.last_name) // problems with spaces and unicode in last name
|
||||
return {u.id, u.first_name, u.username};
|
||||
}
|
||||
|
||||
#define delret delete g; \
|
||||
return true
|
||||
|
||||
|
|
Loading…
Reference in New Issue