title: How to get the list of all chat IDs in a given bot in Telegram?
body: <p>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.</p>
  
  <p>You can view it in this <a href="https://github.com/rubenlagus/TelegramBots" rel="nofollow noreferrer">GitHub Library</a></p>
  
  <p>I have also seen other topics here in stackoverflow <a href="https://stackoverflow.com/questions/32423837/telegram-bot-how-to-get-a-group-chat-id">related</a>.
  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.</p>
  
  <p>Basically I have:</p>
  
  <pre class="lang-java prettyprint-override"><code>public void sendMessage(String message) {
          SendMessage messageSender = new SendMessage().setChatId(someId).setText(message);
          try {
              execute(messageSender);
          } catch (TelegramApiException e) {
              e.printStackTrace();
          }
      }
  </code></pre>
  
  <p>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:</p>
  
  <pre class="lang-java prettyprint-override"><code>List&lt;Integer&gt; chatIds = someMagicRESTendpointOrFunction();
  chatIds.stream().forEach(message -&gt; sendMessage(message));
  </code></pre>