Skype mentions showing "未知用户"
chenjunhua8080 opened this issue · comments
Allen Chen commented
Version
<dependency>
<groupId>com.microsoft.bot</groupId>
<artifactId>bot-integration-spring</artifactId>
<version>4.14.1</version>
<scope>compile</scope>
</dependency>
Code
@Override
protected CompletableFuture<Void> onMessageActivity(TurnContext turnContext) {
// Extract the text from the message activity the user sent.
String text = turnContext.getActivity().getText().toLowerCase();
if (text.contains(" ")){
// bot-allen-001 xxx -> xxx
text = text.substring(text.indexOf(" ") + 1);
}
// Take the input from the user and create the appropriate response.
List<Activity> list = processInput(text, turnContext);
// Respond to the user.
return turnContext
.sendActivities(list)
// .thenCompose(response -> sendSuggestedActions(turnContext))
.thenApply(result -> null);
}
private List<Activity> processInput(String text, TurnContext turnContext) {
ChannelAccount account = turnContext.getActivity().getFrom();
ChannelAccount recipient = turnContext.getActivity().getRecipient();
// String from = String.format("<at id=\"%s\">%s</at>", turnContext.getActivity().getConversation().getId(), account.getName());
String from = String.format("<at id=\"%s\">%s</at>", account.getId(), account.getName());
// String from = String.format("%s, ", account.getName());
// String from = "";
Mention mention = new Mention();
mention.setMentioned(account);
mention.setText(from);
List<Activity> list = Lists.newArrayList();
String msg = "即将运行,一旦有结果我会通知你。ID: " + turnContext.getActivity().getId();
switch (text) {
case "eu19_001:pf":
case "eu19_001:by":
case "eu19_001:raptor":
Activity activity1 = MessageFactory.text(from + text + msg);
activity1.setReplyToId(turnContext.getActivity().getId());
// activity1.setMentions(Lists.newArrayList(mention));
list.add(activity1);
addConversationReference(turnContext.getActivity());
break;
case "help":
list.add(getHelpActivity(from));
break;
default:
Activity activity = MessageFactory.text(from + "请从建议的选项中选择一个通道");
BeanUtils.copyProperties(turnContext.getActivity(), activity,
"id", "timestamp", "from", "recipient", "entities", "text", "channelData");
// activity.setChannelId(Channels.SKYPE);
// HashMap<Object, Object> withChannelData = Maps.newHashMap();
// withChannelData.put("text",activity.getText());
// activity.setChannelData(withChannelData);
activity.setMentions(Lists.newArrayList(mention));
// SkypeMentionNormalizeMiddleware.normalizeSkypeMentionText(activity);
activity.setFrom(recipient);
activity.setRecipient(account);
activity.setSuggestedActions(sendSuggestedActions());
list.add(activity);
break;
}
return list;
}
message
Why is this happening?
Dana V commented
Can you please clarify on the issue? Is the problem that it shows @Allen Chen
in the message but when clicked on, it gives 未知用户
(unknown user)?
Dana V commented
Closing due to lack of response.