atipugin / telegram-bot-ruby

Ruby wrapper for Telegram's Bot API
https://core.telegram.org/bots/api
Do What The F*ck You Want To Public License
1.35k stars 217 forks source link

Add poll_interval option for Client #274

Closed kolasss closed 1 year ago

kolasss commented 1 year ago

set interval for long-polling

atipugin commented 1 year ago

Hi @kolasss,

why do you want to set interval between polling attempts? And why it should be inside #fetch_updates? If for some reason you want to customize polling behavior, you can use your own polling loop:


def do_polling(client)
  loop do
    puts "Polling..."
    client.fetch_updates do |message|
      puts message.inspect
    end

    sleep 1
  end
end

do_polling(Telegram::Bot::Client.new(token))
kolasss commented 1 year ago

@atipugin just a suggestion, I think could be usefull for some people I use interval for 1 second in my code

github-actions[bot] commented 1 year ago

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.