#include "Main.hpp"
#include <tgbot/tgbot.h>
std::vector<int64_t> m_vecChatID;
int main()
{
TgBot::Bot bot( "8165580670" );
bot.getEvents().onCommand( "start" , [&bot]( TgBot::Message::Ptr message )
{
for ( const auto& ChatID : m_vecChatID )
{
if ( ChatID == message->chat->id )
return;
}
//printf( "Command /start add new chat id\n" );
m_vecChatID.emplace_back( message->chat->id );
} );
bot.getEvents().onAnyMessage( [&bot]( TgBot::Message::Ptr message )
{
printf( "User wrote %s\n" , message->text.c_str() );
if ( StringTools::startsWith( message->text , "/start" ) )
return;
for ( const auto& ChatID : m_vecChatID )
{
if ( ChatID == message->chat->id )
return;
}
m_vecChatID.emplace_back( message->chat->id );
for ( const auto& ChatID : m_vecChatID )
{
if ( !message->text.empty() )
{
printf( "SendMessage to: %llu , %s\n" , ChatID , message->text.c_str() );
bot.getApi().sendMessage( ChatID , message->text );
}
}
} );
try
{
printf( "Bot username: %s\n" , bot.getApi().getMe()->username.c_str() );
TgBot::TgLongPoll longPoll( bot );
while ( true )
{
//printf( "Long poll started\n" );
longPoll.start();
}
}
catch ( TgBot::TgException& e )
{
printf( "error: %s\n" , e.what() );
//MessageBoxA( 0 , e.what() , "Error" , MB_ICONERROR );
}
getchar();
return 0;
}
Я делал так, суть в чём, боту пишут люди сообщение к примеру "@randombot 123" и сообщение должно было отправится боту через этого бота, но бот не может писать сообщение другому боту ... и вот схему придумать надо было мол может получится через клиенское апи писать с другого аккаунта боту а он будет пересылать выбраным юзерам сообщение от бота которое он ответил, вот