Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions libraries/botbuilder-core/botbuilder/core/turn_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,11 @@ def remove_recipient_mention(activity: Activity) -> str:
def remove_mention_text(activity: Activity, identifier: str) -> str:
mentions = TurnContext.get_mentions(activity)
for mention in mentions:
if mention.mentioned.id == identifier:
if mention.additional_properties["mentioned"]["id"] == identifier:
mention_name_match = re.match(
r"<at(.*)>(.*?)<\/at>", mention.text, re.IGNORECASE
r"<at(.*)>(.*?)<\/at>",
mention.additional_properties["text"],
re.IGNORECASE,
)
if mention_name_match:
activity.text = re.sub(
Expand Down
12 changes: 7 additions & 5 deletions libraries/botbuilder-core/tests/test_inspection_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
)
from botbuilder.core.adapters import TestAdapter
from botbuilder.core.inspection import InspectionMiddleware, InspectionState
from botbuilder.schema import Activity, ActivityTypes, ChannelAccount, Mention
from botbuilder.schema import Activity, ActivityTypes, ChannelAccount, Entity, Mention


class TestConversationState(aiounittest.AsyncTestCase):
Expand Down Expand Up @@ -249,10 +249,12 @@ async def exec_test2(turn_context):
text=attach_command,
recipient=ChannelAccount(id=recipient_id),
entities=[
Mention(
type="mention",
text=f"<at>{recipient_id}</at>",
mentioned=ChannelAccount(name="Bot", id=recipient_id),
Entity().deserialize(
Mention(
type="mention",
text=f"<at>{recipient_id}</at>",
mentioned=ChannelAccount(name="Bot", id=recipient_id),
).serialize()
)
],
)
Expand Down
11 changes: 7 additions & 4 deletions libraries/botbuilder-core/tests/test_turn_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
ActivityTypes,
ChannelAccount,
ConversationAccount,
Entity,
Mention,
ResourceResponse,
)
Expand Down Expand Up @@ -309,10 +310,12 @@ def test_should_remove_at_mention_from_activity(self):
text="<at>TestOAuth619</at> test activity",
recipient=ChannelAccount(id="TestOAuth619"),
entities=[
Mention(
type="mention",
text="<at>TestOAuth619</at>",
mentioned=ChannelAccount(name="Bot", id="TestOAuth619"),
Entity().deserialize(
Mention(
type="mention",
text="<at>TestOAuth619</at>",
mentioned=ChannelAccount(name="Bot", id="TestOAuth619"),
).serialize()
)
],
)
Expand Down