1
0
зеркало из https://github.com/glebtv/telegram-bot.git synced 2026-08-28 15:26:18 +03:00
Files
telegram-bot/lib/tasks/telegram-bot.rake
2025-01-02 22:13:01 -05:00

45 строки
1.4 KiB
Ruby

# frozen_string_literal: true
namespace :telegram do
namespace :bot do
desc 'Run poller. It broadcasts Rails.logger to STDOUT in dev like `rails s` do. ' \
'Use LOG_TO_STDOUT to enable/disable broadcasting.'
task :poller do
ENV['BOT_POLLER_MODE'] = 'true'
Rake::Task['environment'].invoke
if ENV.fetch('LOG_TO_STDOUT') { Rails.env.development? }.present?
console = ActiveSupport::Logger.new($stderr)
if Rails.logger.respond_to?(:broadcast_to)
Rails.logger.broadcast_to(console)
else
Rails.logger.extend ActiveSupport::Logger.broadcast console
end
end
# Routes are not loaded by default in Rails >= 8.0.
# Load them explicitly to identify a controller for a bot.
Rails.application.try(:reload_routes_unless_loaded)
Telegram::Bot::UpdatesPoller.start(ENV['BOT']&.to_sym || :default)
end
desc 'Set webhook urls for all bots'
task set_webhook: :environment do
Telegram::Bot::Tasks.set_webhook
end
desc 'Delete webhooks for all or specific BOT'
task :delete_webhook do
Telegram::Bot::Tasks.delete_webhook
end
desc 'Perform logOut command for all or specific BOT'
task :log_out do
Telegram::Bot::Tasks.log_out
end
desc 'Perform `close` command for all or specific BOT'
task :close do
Telegram::Bot::Tasks.close
end
end
end