i built by using java a telegram bot which basically get users's name it can be 1 or 10 or even 40 (i limited it to 50) depends on how much you want to put now the purpose of this bot is later on when you finish with your specific users you write a message to send them
now everything is work perfect the id names getting save as well the message although how do i send it to all the users i just insert as a private message if it even possible... by command
i hope i was understandable enough
thats my code:
class Bot extends TelegramLongPollingBot {
public int counter = 0;
public ArrayList names = new ArrayList(50);
public SendMessage mainMessage = new SendMessage();
public String sgMsg = "";
public StringBuilder stringBuilder = new StringBuilder();
public String msg;
public void onUpdateReceived(Update update) {
String command = update.getMessage().getText();
SendMessage sysMsg = new SendMessage();
sysMsg.setChatId(update.getMessage().getChatId());
String firstCdletter;
firstCdletter = Character.toString(command.charAt(0));
if (command.equals("/start")) {
sysMsg.setText("Enter the user's id, to finish send: Ok");
try {
execute(sysMsg);
} catch (TelegramApiException e) {
e.printStackTrace();
}
counter = 0;
names.clear();
sgMsg = "";
}else if (firstCdletter.equals("@")) {
String user = command;
names.add(counter);
counter++;
}else if(command.equals("/ok")){
sysMsg.setText("Good, now write your message you want to deliver");
try {
execute(sysMsg);
} catch (TelegramApiException e) {
e.printStackTrace();
}
}else if(command.equals("/done")){
msg = stringBuilder.toString();
}else{
sgMsg = update.getMessage().getText();
stringBuilder.append(sgMsg + " ");
}
}
thank you all for your time and help