Closed chenjunhua8080 closed 4 months ago
<dependency> <groupId>com.microsoft.bot</groupId> <artifactId>bot-integration-spring</artifactId> <version>4.14.1</version> <scope>compile</scope> </dependency>
@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; }
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)?
@Allen Chen
未知用户
Closing due to lack of response.
Version
Code
message
Why is this happening?