sendPhoto
Introduction
Process
public class HandleToLessonThree extends TelegramLongPollingBot {
@Override
public void onUpdateReceived(Update update) {
if (update.hasMessage() && update.getMessage().hasText()) {
// Initialization received message
String message_text = update.getMessage().getText();
// Initialization sendMessage
SendMessage message = new SendMessage();
// In advance set chat id to sendMessage
message.setChatId(update.getMessage().getChatId().toString());
switch (message_text) {
case "/start" -> message.setText("All is working");
case "want picture" -> {
try {
sendPhoto(update, "test.png");
} catch (TelegramApiException | FileNotFoundException e) {
e.printStackTrace();
}
message.setText("Photo is sent");
}
}
}
}
}
Last updated