Sha256: 74e8009a0afa9e6dcf49197547ad6b8b9622099d5e3d501509abc293710acfdc

Contents?: true

Size: 795 Bytes

Versions: 5

Compression:

Stored size: 795 Bytes

Contents

namespace :telegram do
  namespace :bot do
    desc 'Run poller'
    task poller: :environment do
      console = ActiveSupport::Logger.new(STDERR)
      Rails.logger.extend ActiveSupport::Logger.broadcast console
      Telegram::Bot::UpdatesPoller.start(ENV['BOT'].try!(:to_sym) || :default)
    end

    desc 'Set webhook urls for all bots'
    task set_webhook: :environment do
      routes = Rails.application.routes.url_helpers
      cert_file = ENV['CERT']
      cert = File.open(cert_file) if cert_file
      Telegram.bots.each do |key, bot|
        route_name = Telegram::Bot::RoutesHelper.route_name_for_bot(bot)
        url = routes.send("#{route_name}_url")
        puts "Setting webhook for #{key}..."
        bot.set_webhook(url: url, certificate: cert)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
telegram-bot-0.7.2 lib/tasks/telegram-bot.rake
telegram-bot-0.6.0 lib/tasks/telegram-bot.rake
telegram-bot-0.5.0 lib/tasks/telegram-bot.rake
telegram-bot-0.4.2 lib/tasks/telegram-bot.rake
telegram-bot-0.4.1 lib/tasks/telegram-bot.rake