telegram-bot-ruby
telegram-bot-ruby copied to clipboard
Send bulk messages to "subscribers"?
First thanks for the gem. I had my first nonsense bot up and running within a hour.
I would like to send notifications to all "subscribed" users/channels. As in any who have my bot in their channel and/or wrote /subscribe to him. Is that possible? I checked the code and the examples and did not really find a solution that looks like it would work without initial trigger from Telegram itself.
Hi,
I created this ruby script and run it manually to announce something (in my case, updates to the bot):
load 'Rakefile'
updates = "latest updates:\n"
updates += "- updated gem to Telegram Bot API 2.0 and adapted changes\n"
updates += "- other updates\n"
updates += "- moar updates\n"
updates += "- even moar updates"
groups = MyModule::Group.all.map(&:group_id).uniq
Telegram::Bot::Client.run($token) do |bot|
groups.each do |g|
bot.api.send_message(chat_id: g, text: updates) rescue nil # in case the bot was kicked/blocked
end
end
but of course it'd be nice to have something from the gem to handle this too
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.