Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callbacks not registered OR longpool doesn't work #283

Open
asprs opened this issue Jul 14, 2023 · 1 comment
Open

Callbacks not registered OR longpool doesn't work #283

asprs opened this issue Jul 14, 2023 · 1 comment

Comments

@asprs
Copy link

asprs commented Jul 14, 2023

Guys,
I'm stuck.
I don't receive any message. Why?
Please help.

#include <stdio.h>
#include <tgbot/tgbot.h>

#include "config.h"
#include "logger.h"

namespace broker
{
class telegram_bot
{
public:
TgBot::Bot bot;

    telegram_bot() : bot(config::telegram_bot.token)
{
    bot.getEvents().onAnyMessage(std::bind(&telegram_bot::on_start, this, std::placeholders::_1));
        new std::thread(&telegram_bot::work, this);
    }

    void work()
    {
        try
        {
            TgBot::TgLongPoll longPoll(bot);

            while (true)
            {
                LOG_INFO << "[telegram_bot] " << " Long pool started";
                longPoll.start();
            }

            LOG_INFO << "[telegram_bot] " << " Exit"; 
    }
        catch (const std::exception &e)
        {
            LOG_ERROR << "[telegram_bot] " << " error: " << e.what();
        }
    }

    void on_start(const TgBot::Message::Ptr message)
    {
        cout << "work" << endl;
    }
};

}

@asprs asprs changed the title Callbacks not registred OR longpool doesn't work Callbacks not registered OR longpool doesn't work Jul 14, 2023
@asprs
Copy link
Author

asprs commented Jul 14, 2023

going deeper into investigation I've created simple bot form main example and found that

TgBot::Bot bot(,,,);
bot.getApi().deleteWebhook();

just hangs w/o any exception or return

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant