tele-broadcast.cr alternatives and similar shards
Based on the "Framework Components" category
Do you think we are missing an alternative of tele-broadcast.cr or a related project?
A broadcasting module for Tele.cr.
Add this to your application's
dependencies: tele-broadcast: github: vladfaust/tele-broadcast.cr version: ~> 0.1.3
Read some docs when you need.
Tele::Broadcast is agnostic of ORM structure, you just pass a list of
Tele::Requests and an list of recipients chat IDs and run the Woker. You can either create a custom CLI for broadcasting from the local machine or develop a web-interface.
The client allows to schedule broadcasts:
require "tele/requests/send_message" require "tele-broadcast/client" require "tele-broadcast/repositories/redis" logger = Logger.new(STDOUT).tap(&.level = Logger::DEBUG) repo = Tele::Broadcast::Repositories::Redis.new(Redis.new, logger, "example_bot:broadcast:") # Don't forget to add a colon in the end of namespace client = Tele::Broadcast::Client.new(repo, logger) request = Tele::Requests::SendMessage.new(chat_id: 0, text: "Hello from Tele::Broadcast!") recipients = [116543174, 155633478] of Int32 # A list of Telegram IDs client.broadcast(requests, recipients) # => INFO -- : Added payload #1 to the broadcasting queue
examples/client.cr and try it yourself:
crystal /examples/client.cr -- --text="Hola!" -r <Your Telegram ID>
Please not that you have to contact the bot at least once so it can send you messages.
The worker periodically checks for new broadcasts and handles them:
require "tele-broadcast/worker" require "tele-broadcast/repositories/redis" logger = Logger.new(STDOUT).tap(&.level = Logger::DEBUG) repo = Tele::Broadcast::Repositories::Redis.new(Redis.new, logger, "example_bot:broadcast:") # Don't forget to add a colon in the end of namespace worker = Tele::Broadcast::Worker.new("BOT_API_TOKEN", repo, logger) worker.run # => INFO -- : Tele::Broadcast::Worker worker is running! # => INFO -- : Started broadcasting payload #1 to 2 recipients... # => DEBUG -- : Recipient 116543174 has blocked the bot, skipping # => DEBUG -- : Sending request #727 to 155633478... # => DEBUG -- : Delivered request #727 in 0.29s # => INFO -- : Done broadcasting payload #1 in 0.29s!
Try it yourself:
crystal /examples/worker.cr -- -t <BOT_API_TOKEN>
There are tests! So please run
crystal spec while developing.
- Fork it ( https://github.com/vladfaust/tele-broadcast.cr/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
- @vladfaust Vlad Faust - creator, maintainer