Improve example result handler
This commit is contained in:
parent
250dfa3a89
commit
4999183324
|
@ -152,21 +152,18 @@ public final class Example {
|
||||||
long chatId = update.message.chatId;
|
long chatId = update.message.chatId;
|
||||||
|
|
||||||
// Get the chat title
|
// Get the chat title
|
||||||
client.send(new TdApi.GetChat(chatId))
|
client.send(new TdApi.GetChat(chatId)).whenCompleteAsync((chatIdResult, error) -> {
|
||||||
.thenApply(chatIdResult -> {
|
if (error != null) {
|
||||||
// Get the chat name
|
// Print error
|
||||||
return chatIdResult.title;
|
System.err.printf("Can't get chat title of chat %s%n", chatId);
|
||||||
})
|
error.printStackTrace(System.err);
|
||||||
.whenComplete((chatTitle, error) -> {
|
} else {
|
||||||
if (error != null) {
|
// Get the chat name
|
||||||
// Print error
|
String title = chatIdResult.title;
|
||||||
System.err.printf("Can't get chat title of chat %s%n", chatId);
|
// Print the message
|
||||||
error.printStackTrace(System.err);
|
System.out.printf("Received new message from chat %s (%s): %s%n", title, chatId, text);
|
||||||
} else {
|
}
|
||||||
// Print the message
|
});
|
||||||
System.out.printf("Received new message from chat %s (%s): %s%n", chatTitle, chatId, text);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user