lib/telegram/bot/tasks.rb in telegram-bot-0.16.1 vs lib/telegram/bot/tasks.rb in telegram-bot-0.16.3

- old
+ new

@@ -5,20 +5,20 @@ module Tasks extend self def set_webhook routes = Rails.application.routes.url_helpers - cert_file = ENV['CERT'] + cert_file = ENV.fetch('CERT', nil) cert = File.open(cert_file) if cert_file each_bot do |key, bot| route_name = RoutesHelper.route_name_for_bot(bot) url = routes.send("#{route_name}_url") say("Setting webhook for #{key}...") bot.set_webhook( url: url, certificate: cert, - ip_address: ENV['IP_ADDRESS'], + ip_address: ENV.fetch('IP_ADDRESS', nil), drop_pending_updates: drop_pending_updates, ) end end @@ -48,16 +48,16 @@ def say(text) puts(text) unless Rails.env.test? # rubocop:disable Rails/Output end def each_bot(&block) - id = ENV['BOT'].try!(:to_sym) + id = ENV['BOT']&.to_sym bots = id ? {id => Client.by_id(id)} : Telegram.bots bots.each { |key, bot| bot.async(false) { block[key, bot] } } end def drop_pending_updates - ENV['DROP_PENDING_UPDATES'].try!(:downcase) == 'true' + ENV['DROP_PENDING_UPDATES']&.downcase == 'true' end end end end