Skip to content

Commit 69eb01b

Browse files
committed
fix: initialize TelegramBotWorkerJob after initialize
1 parent 77e332f commit 69eb01b

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
require "telegram/bot"
1+
# Only run this code when the Rails server is starting.
2+
# This prevents it from running during `assets:precompile`, `db:migrate`, etc.
23

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"
4+
if defined?(Rails::Server)
5+
require "telegram/bot"
6+
Rails.application.config.after_initialize do
7+
token = Rails.application.credentials.dig(:telegram_bot_token)
8+
TelegramBotWorkerJob.perform_later(token) if token
109
end
1110
end

0 commit comments

Comments
 (0)