Class: TelegramBotEngine::DeliveryJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/telegram_bot_engine/delivery_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(chat_id, text, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'app/jobs/telegram_bot_engine/delivery_job.rb', line 8

def perform(chat_id, text, options = {})
  Telegram.bot.send_message(
    chat_id: chat_id,
    text: text,
    **options.symbolize_keys
  )
rescue Telegram::Bot::Forbidden
  # User blocked the bot - deactivate subscription
  TelegramBotEngine::Subscription.where(chat_id: chat_id).update_all(active: false)
  Rails.logger.info("[TelegramBotEngine] Deactivated subscription for blocked chat: #{chat_id}")
end