From 8a69fdc81fae0ed6736d399adcac376e6fe713c8 Mon Sep 17 00:00:00 2001 From: mrbesen Date: Tue, 15 Mar 2022 19:57:25 +0100 Subject: [PATCH] auto join game --- src/bot.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/bot.cpp b/src/bot.cpp index 3c4fe1e..28580a3 100644 --- a/src/bot.cpp +++ b/src/bot.cpp @@ -2,6 +2,11 @@ #include +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 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