Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RemoveRecipientMention does not remove a Skype bot mention #1934

Closed
EricDahlvang opened this issue May 22, 2019 · 1 comment
Closed

RemoveRecipientMention does not remove a Skype bot mention #1934

EricDahlvang opened this issue May 22, 2019 · 1 comment

Comments

@EricDahlvang
Copy link
Member

Version

All versions (including V3)

Describe the bug

When a bot is @mentioned on the Skype channel, it will receive a mention.Text in the following format:

Skype
Text: "healthtest this is just a test"

{{
  "mentioned": {
    "id": "28:2bc5b54d-5d48-4ff1-bd25-03dcbb5ce918"
  },
  "text": "<at id=\"28:2bc5b54d-5d48-4ff1-bd25-03dcbb5ce918\">healthtest</at>"
}}

Due to this, ActivityExtensions.RemoveRecipientMention does nothing on Skype. Other channels send @mentions in this format:

Teams
Text:"<at>healthtest</at> this is a test\n"

{{
  "mentioned": {
    "id": "28:2bc5b54d-5d48-4ff1-bd25-03dcbb5ce918",
    "name": "healthtest"
  },
  "text": "<at>healthtest</at>"
}}

To Reproduce

Steps to reproduce the behavior:

  1. Add a bot to a Skype group chat
  2. @mention the bot
  3. Call turnContext.Activity.RemoveRecipientMention();
  4. Echo the text back to the user
  5. Notice that the bot @mention is not removed

Expected behavior

Either 1) the skype connector service should send @mentions in a format similar to teams or 2) the RemoveRecipientMention should handle Skype @mentions

Screenshots

image

Additional context

Ugly workaround for Skype bots:

            foreach (var mention in turnContext.Activity.GetMentions().Where(mention => mention.Mentioned.Id == turnContext.Activity.Recipient.Id))
            {
                int index = mention.Text.IndexOf('>');
                var nextIndex = mention.Text.IndexOf('<', index);
                var mentionText = mention.Text.Substring(index + 1, nextIndex - index - 1);
                turnContext.Activity.Text = turnContext.Activity.Text.Replace(mentionText, "").Trim();
            }

[bug]

@garypretty
Copy link
Contributor

Opened PR #1935 for this - saw it thought it would probably be a quick fix. I have changed the logic to first grab the mentioned display name using a regex and strip it, which should work for all channels. Then clean up any left over empty tags.

Altered to....

foreach (var mention in activity.GetMentions().Where(mention => mention.Mentioned.Id == id))
            {
                var mentionNameMatch = Regex.Match(mention.Text, @"(?<=<at.*>)(.*?)(?=<\/at>)", RegexOptions.IgnoreCase);
                if (mentionNameMatch.Success)
                {
                    activity.Text = activity.Text.Replace(mentionNameMatch.Value, string.Empty);
                    activity.Text = Regex.Replace(activity.Text, "<at></at>", string.Empty, RegexOptions.IgnoreCase);
                }
            }

tomlm pushed a commit that referenced this issue Jun 12, 2019
Fix for #1934 skype channel not stripping mentions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants