xooniverse / televerse

Your gateway to seamless Telegram Bot Development 💙
https://televerse.xooniverse.com
BSD 3-Clause "New" or "Revised" License
64 stars 11 forks source link

How to check if the bot instance is already running or not? #147

Closed OttomanDeveloper closed 1 year ago

OttomanDeveloper commented 1 year ago

How to check if the bot instance is already running or not? I'm getting this error.

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: LongPollingException [null]: Already polling. You cannot start another polling when another polling is working.

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: TelegramException [429]: (Too Many Requests: retry after 94)

HeySreelal commented 1 year ago

Are you calling the Televerse.start method more than once? It might possibly cause this exception to be thrown.

Hmm, seems an interesting topic. As of now, there's no way you can check if a bot is already started the polling or not.

HeySreelal commented 1 year ago

Btw, as you're using LongPolling as fetcher, you can already check if the long polling is active:

    if((bot.fetcher as LongPolling).isPolling) {
      print('Polling is active');
    } else {
      print('Polling is not active');
    }
OttomanDeveloper commented 1 year ago

Thank you it's working

HeySreelal commented 1 year ago

Happy to help! Happy Televersing! 🚀