witnessmenow / Universal-Arduino-Telegram-Bot

Use Telegram on your Arduino (ESP8266 or Wifi-101 boards)
MIT License
1.09k stars 302 forks source link

It not really issue #262

Open ghost opened 2 years ago

ghost commented 2 years ago

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

do8pgg commented 2 years ago

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;
        }
      }
    }
  }
      …
} 
tglaria commented 2 years ago

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.

Esque123 commented 1 year ago

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.