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,
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/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, Subscription
Constant Summary collapse
- VERSION =
"0.2.1"
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 |
# File 'lib/telegram_bot_engine.rb', line 25 def broadcast(text, **) TelegramBotEngine::Subscription.active.find_each do |subscription| TelegramBotEngine::DeliveryJob.perform_later( subscription.chat_id, text, ) end 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
36 37 38 |
# File 'lib/telegram_bot_engine.rb', line 36 def notify(chat_id:, text:, **) TelegramBotEngine::DeliveryJob.perform_later(chat_id, text, ) end |
.reset_config! ⇒ Object
20 21 22 |
# File 'lib/telegram_bot_engine.rb', line 20 def reset_config! @config = Configuration.new end |