Fix FAQ.md according to API changes
This commit is contained in:
parent
b2fcbaa3c2
commit
bd2aa24e00
@ -116,7 +116,7 @@ There are several method to send a photo to an user using `sendPhoto` method: Wi
|
|||||||
// Set destination chat id
|
// Set destination chat id
|
||||||
sendPhotoRequest.setChatId(chatId);
|
sendPhotoRequest.setChatId(chatId);
|
||||||
// Set the photo url as a simple photo
|
// Set the photo url as a simple photo
|
||||||
sendPhotoRequest.setPhoto(url);
|
sendPhotoRequest.setPhoto(new InputFile(url));
|
||||||
try {
|
try {
|
||||||
// Execute the method
|
// Execute the method
|
||||||
execute(sendPhotoRequest);
|
execute(sendPhotoRequest);
|
||||||
@ -131,7 +131,7 @@ There are several method to send a photo to an user using `sendPhoto` method: Wi
|
|||||||
// Set destination chat id
|
// Set destination chat id
|
||||||
sendPhotoRequest.setChatId(chatId);
|
sendPhotoRequest.setChatId(chatId);
|
||||||
// Set the photo url as a simple photo
|
// Set the photo url as a simple photo
|
||||||
sendPhotoRequest.setPhoto(fileId);
|
sendPhotoRequest.setPhoto(new InputFile(fileId));
|
||||||
try {
|
try {
|
||||||
// Execute the method
|
// Execute the method
|
||||||
execute(sendPhotoRequest);
|
execute(sendPhotoRequest);
|
||||||
@ -145,8 +145,8 @@ There are several method to send a photo to an user using `sendPhoto` method: Wi
|
|||||||
SendPhoto sendPhotoRequest = new SendPhoto();
|
SendPhoto sendPhotoRequest = new SendPhoto();
|
||||||
// Set destination chat id
|
// Set destination chat id
|
||||||
sendPhotoRequest.setChatId(chatId);
|
sendPhotoRequest.setChatId(chatId);
|
||||||
// Set the photo file as a new photo (You can also use InputStream with a method overload)
|
// Set the photo file as a new photo (You can also use InputStream with a constructor overload)
|
||||||
sendPhotoRequest.setNewPhoto(new File(filePath));
|
sendPhotoRequest.setPhoto(new InputFile(new File(filePath)));
|
||||||
try {
|
try {
|
||||||
// Execute the method
|
// Execute the method
|
||||||
execute(sendPhotoRequest);
|
execute(sendPhotoRequest);
|
||||||
@ -166,20 +166,19 @@ if (update.hasMessage() && update.getMessage().hasPhoto()) {
|
|||||||
List<PhotoSize> photos = update.getMessage().getPhoto();
|
List<PhotoSize> photos = update.getMessage().getPhoto();
|
||||||
// Get largest photo's file_id
|
// Get largest photo's file_id
|
||||||
String f_id = photos.stream()
|
String f_id = photos.stream()
|
||||||
.sorted(Comparator.comparing(PhotoSize::getFileSize).reversed())
|
.max(Comparator.comparing(PhotoSize::getFileSize))
|
||||||
.findFirst()
|
.orElseThrow().getFileId();
|
||||||
.orElse(null).getFileId();
|
|
||||||
// Send photo by file_id we got before
|
// Send photo by file_id we got before
|
||||||
SendPhoto msg = new SendPhoto()
|
SendPhoto msg = new SendPhoto()
|
||||||
.setChatId(update.getMessage().getChatId())
|
.setChatId(update.getMessage().getChatId())
|
||||||
.setPhoto(f_id)
|
.setPhoto(new InputFile(f_id))
|
||||||
.setCaption("Photo");
|
.setCaption("Photo");
|
||||||
try {
|
try {
|
||||||
execute(msg); // Call method to send the photo
|
execute(msg); // Call method to send the photo
|
||||||
} catch (TelegramApiException e) {
|
} catch (TelegramApiException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## <a id="how_to_use_custom_keyboards"></a>How to use custom keyboards? ##
|
## <a id="how_to_use_custom_keyboards"></a>How to use custom keyboards? ##
|
||||||
|
Loading…
Reference in New Issue
Block a user