Universal-Arduino-Telegram-Bot icon indicating copy to clipboard operation
Universal-Arduino-Telegram-Bot copied to clipboard

It not really issue

Open ghost opened this issue 3 years ago • 3 comments

is there a way to add more then 1 chat id currently I'm using String CHAT_ID = "chat id here";

ghost avatar Nov 16 '21 14:11 ghost

this is how I did it. Not pretty, but does what it should.

if (chat_id != 0123456789) {
  if (chat_id != 1234567890) {
    if (chat_id != 2345678901) {
      if (chat_id != 3456789012) {
        if (chat_id != 4567890123) {
          …
          bot.sendMessage(chat_id, „nope!“, „“);
          continue;
        }
      }
    }
  }
      …
} 

do8pgg avatar Dec 15 '21 06:12 do8pgg

this is how I did it. Not pretty, but does what it should.

if (chat_id != 0123456789) {
  if (chat_id != 1234567890) {
    if (chat_id != 2345678901) {
      if (chat_id != 3456789012) {
        if (chat_id != 4567890123) {
          …
          bot.sendMessage(chat_id, „nope!“, „“);
          continue;
        }
      }
    }
  }
      …
} 

You might want to try with switch() case.

tglaria avatar May 30 '22 22:05 tglaria

You should be able to put the chat_id's into an array and then just use a for loop to loop through the array sending to "nope!" message to each chat id as it goes through each iteration of the loop.

Esque123 avatar Aug 30 '22 09:08 Esque123