Advertisement
Cool_boy21

Untitled

Mar 15th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.52 KB | None | 0 0
  1. @Override
  2. public void onUpdateReceived(Update update) {
  3.  if (update.hasMessage()) {
  4.   long chat_id = update.getMessage().getChatId();
  5.  
  6.   List < PhotoSize > photos = update.getMessage().getPhoto();
  7.  
  8.   String f_id = photos.stream()
  9.    .sorted(Comparator.comparing(PhotoSize::getFileSize).reversed())
  10.    .findFirst()
  11.    .orElse(null).getFileId();
  12.   SendPhoto msg = new SendPhoto()
  13.    .setChatId(chat_id)
  14.    .setPhoto(f_id);
  15.   try {
  16.    sendPhoto(msg);
  17.   } catch (TelegramApiException e) {
  18.    e.printStackTrace();
  19.   }
  20.  }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement