We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 77e332f commit 69eb01bCopy full SHA for 69eb01b
config/initializers/telegram_bot.rb
@@ -1,11 +1,10 @@
1
-require "telegram/bot"
+# Only run this code when the Rails server is starting.
2
+# This prevents it from running during `assets:precompile`, `db:migrate`, etc.
3
-# Set up the telegram bot configuration for all Rails processes
4
-Rails.application.configure do
5
- token = Rails.application.credentials.dig(:telegram_bot_token)
6
- if token
7
- config.telegram_bot = Telegram::Bot::Client.new(token)
8
- else
9
- Rails.logger.warn "Telegram bot token not found in credentials"
+if defined?(Rails::Server)
+ require "telegram/bot"
+ Rails.application.config.after_initialize do
+ token = Rails.application.credentials.dig(:telegram_bot_token)
+ TelegramBotWorkerJob.perform_later(token) if token
10
end
11
0 commit comments