use the "Group member profile API" in kitchensink example.
@@ -280,11 +280,32 @@ public class KitchenSinkController {
throws Exception {
String text = content.getText();
- log.info("Got text message from {}: {}", replyToken, text);
+ log.info("Got text message from replyToken:{}: text:{}", replyToken, text);
switch (text) {
case "profile": {
+ log.info("Invoking 'profile' command: source:{}",
+ event.getSource());
String userId = event.getSource().getUserId();
if (userId != null) {
+ if (event.getSource() instanceof GroupSource) {
+ lineMessagingClient
+ .getGroupMemberProfile(((GroupSource) event.getSource()).getGroupId(), userId)
+ .whenComplete((profile, throwable) -> {
+ if (throwable != null) {
+ this.replyText(replyToken, throwable.getMessage());
+ return;
+ }
+
+ this.reply(
+ replyToken,
+ Arrays.asList(new TextMessage("(from group)"),
+ new TextMessage(
+ "Display name: " + profile.getDisplayName()),
+ new ImageMessage(profile.getPictureUrl(),
+ profile.getPictureUrl()))
+ );
+ });
+ } else {
lineMessagingClient
.getProfile(userId)
.whenComplete((profile, throwable) -> {
@@ -302,6 +323,7 @@ public class KitchenSinkController {
);
});
+ }
} else {
this.replyText(replyToken, "Bot can't use profile API without user ID");
}
@@ -470,7 +492,8 @@ public class KitchenSinkController {
.area(new ImagemapArea(40, 46, 952, 536))
.externalLink(
new ImagemapExternalLink(
- URI.create("https://example.com/see_more.html"), "See More")
+ URI.create("https://example.com/see_more.html"),
+ "See More")
)
.build()
)
