Module: TelegramBotEngine
- Defined in:
- lib/telegram_bot_engine.rb,
lib/telegram_bot_engine/engine.rb,
lib/telegram_bot_engine/version.rb,
lib/telegram_bot_engine/authorizer.rb,
app/models/telegram_bot_engine/event.rb,
lib/telegram_bot_engine/configuration.rb,
app/jobs/telegram_bot_engine/delivery_job.rb,
app/models/telegram_bot_engine/allowed_user.rb,
app/models/telegram_bot_engine/subscription.rb,
lib/telegram_bot_engine/subscriber_commands.rb,
app/controllers/telegram_bot_engine/admin/base_controller.rb,
app/controllers/telegram_bot_engine/admin/events_controller.rb,
app/controllers/telegram_bot_engine/admin/allowlist_controller.rb,
app/controllers/telegram_bot_engine/admin/dashboard_controller.rb,
app/controllers/telegram_bot_engine/admin/subscriptions_controller.rb
Defined Under Namespace
Modules: Admin, SubscriberCommands Classes: AllowedUser, Authorizer, Configuration, DeliveryJob, Engine, Event, Subscription
Constant Summary collapse
- VERSION =
"0.3.4"
Class Method Summary collapse
-
.broadcast(text, **options) ⇒ Object
Broadcast to all active subscribers via background jobs.
- .config ⇒ Object
- .configure {|config| ... } ⇒ Object
-
.notify(chat_id:, text:, **options) ⇒ Object
Send to a specific chat via background job.
- .reset_config! ⇒ Object
Class Method Details
.broadcast(text, **options) ⇒ Object
Broadcast to all active subscribers via background jobs
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/telegram_bot_engine.rb', line 25 def broadcast(text, **) subscriber_count = 0 TelegramBotEngine::Subscription.active.find_each do |subscription| TelegramBotEngine::DeliveryJob.perform_later( subscription.chat_id, text, ) subscriber_count += 1 end TelegramBotEngine::Event.log( event_type: "delivery", action: "broadcast", details: { subscriber_count: subscriber_count, text_preview: text.to_s[0, 100] } ) end |
.config ⇒ Object
16 17 18 |
# File 'lib/telegram_bot_engine.rb', line 16 def config @config ||= Configuration.new end |
.configure {|config| ... } ⇒ Object
12 13 14 |
# File 'lib/telegram_bot_engine.rb', line 12 def configure yield(config) end |
.notify(chat_id:, text:, **options) ⇒ Object
Send to a specific chat via background job
43 44 45 46 47 48 49 50 51 |
# File 'lib/telegram_bot_engine.rb', line 43 def notify(chat_id:, text:, **) TelegramBotEngine::DeliveryJob.perform_later(chat_id, text, ) TelegramBotEngine::Event.log( event_type: "delivery", action: "notify", chat_id: chat_id, details: { text_preview: text.to_s[0, 100] } ) end |
.reset_config! ⇒ Object
20 21 22 |
# File 'lib/telegram_bot_engine.rb', line 20 def reset_config! @config = Configuration.new end |