question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bot.telegram.sendMessage timeout needed?

See original GitHub issue

https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once

When sending messages inside a particular chat, avoid sending more than one message per second. We may allow short bursts that go over this limit, but eventually you’ll begin receiving 429 errors. If you’re sending bulk notifications to multiple users, the API will not allow more than 30 messages per second or so. Consider spreading out notifications over large intervals of 8—12 hours for best results. Also note that your bot will not be able to send more than 20 messages per minute to the same group.

Telegraf have 30message/seconds delay if i use bot.telegram.sendMessage(chat.id, '...'); ?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
ptkdevcommented, Sep 18, 2020

@AndreoliBR install system-sleep from npm, example:

    function check_database(json){
        let sleep = require('system-sleep');
        db.serialize(function() {
            let limit = 0;
            db.each("SELECT rowid AS id, chat_id, last_url FROM users", function(err, row) {
                let last_url = null;
                let chat_id = null;
                let i = 0;
                for (i = 0; i < config.wp_total_feed && i < json.rss.channel[0].item.length; i++) {
                    let url = json.rss.channel[0].item[i].link[0].replace("'", "");
                    if(i == 0){
                        last_url = url;
                        chat_id = row.chat_id;
                    }
                    if(url == row.last_url)
                        break;

                    bot.telegram.sendMessage(row.chat_id, url);
                    limit++;

                    if(limit >= 29){ // bug: https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once
                        sleep(1000);
                        limit = 0;
                    }
                }

                if(i > 0){
                    db.run("UPDATE users SET last_url = ? WHERE chat_id = ?", last_url, chat_id);
                }
            });
        });
    }
1reaction
ptkdevcommented, Sep 20, 2020

@AndreoliBR great! Nice bro!

Read more comments on GitHub >

github_iconTop Results From Across the Web

TimedOut in python-telegram-bot but message is sent
Time out errors mean that TG didn't send a response to your send_message request quick enough. It does not necessarily mean that the...
Read more >
Python telegram.error.TimedOut() Examples
This page shows Python examples of telegram.error.TimedOut. ... sendMessage(chat_id=chat_id, text=message) except BadRequest as e: bot.
Read more >
python-telegram-bot v20.0b0
This object represents a Telegram Bot. Most bot methods have the argument api_kwargs which allows passing arbitrary keywords to the Telegram API. This...
Read more >
Telegram Bot API
All queries to the Telegram Bot API must be served over HTTPS and need to be presented in this form: https://api.telegram.org/bot<token>/METHOD_NAME .
Read more >
telegram bot socket.timeout: timed out : Forums
telegram bot socket.timeout: timed out. hi there, my code works very well last night,. but today have problem.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found