telegram-bot-ruby icon indicating copy to clipboard operation
telegram-bot-ruby copied to clipboard

Send bulk messages to "subscribers"?

Open b1nary opened this issue 8 years ago • 1 comments

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.

b1nary avatar Apr 13 '16 15:04 b1nary

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

araishikeiwai avatar Apr 13 '16 21:04 araishikeiwai

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.

github-actions[bot] avatar Feb 19 '23 15:02 github-actions[bot]