I am creating a telegram bot using a CRON job so it will update with every interesting movie/series release, and I want it to send an update once every month.
You can view it in this GitHub Library
I have also seen other topics here in stackoverflow related. But, this kind of solution does not apply to my problem, or I think so at least, since I do not have to have updates from every chat that my bot will be into since it will be a newsletter bot.
Basically I have:
public void sendMessage(String message) {
SendMessage messageSender = new SendMessage().setChatId(someId).setText(message);
try {
execute(messageSender);
} catch (TelegramApiException e) {
e.printStackTrace();
}
}
Which is fine to send one message if you already know the chatId you want to send the message to. But, I would like to have a function (or a REST endpoint) that returns the list of chetIds my bot is attached to so that I can go for something like:
List<Integer> chatIds = someMagicRESTendpointOrFunction();
chatIds.stream().forEach(message -> sendMessage(message));