-
Notifications
You must be signed in to change notification settings - Fork 305
Description
Hello,
Version
botbuilder-core==4.5.0b4
botbuilder-schema==4.5.0b4
botframework-connector==4.5.0b4
Describe the bug
When I am trying to remove recipient mention from a text of activity to further parse a command from it, it raises an error: *** AttributeError: 'Entity' object has no attribute 'mentioned'
To Reproduce
Send a message to your bot with mention and some text, for example @Bot hello.
The Activity object will contain entities:
(Pdb) pp turn_context.activity.__dict__
{'action': None,
'additional_properties': {},
'attachment_layout': None,
'attachments': [<botbuilder.schema._models_py3.Attachment object at 0x7fc3354dd518>],
'caller_id': None,
'channel_data': {'tenant': {'id': '...'}},
'channel_id': 'msteams',
'code': None,
'conversation': <botbuilder.schema._models_py3.ConversationAccount object at 0x7fc3354dd710>,
'delivery_mode': None,
'entities': [<botbuilder.schema._models_py3.Entity object at 0x7fc3354ddb38>,
<botbuilder.schema._models_py3.Entity object at 0x7fc3354dd2e8>],
'expiration': None,
'from_property': <botbuilder.schema._models_py3.ChannelAccount object at 0x7fc3354dd5c0>,
'history_disclosed': None,
'id': '...',
'importance': None,
'input_hint': None,
'label': None,
'listen_for': None,
'local_timestamp': datetime.datetime(2019, 12, 11, 12, 51, 44, 23987, tzinfo=<FixedOffset '+03:00'>),
'local_timezone': None,
'locale': 'en-US',
'members_added': None,
'members_removed': None,
'name': None,
'reactions_added': None,
'reactions_removed': None,
'recipient': <botbuilder.schema._models_py3.ChannelAccount object at 0x7fc3354ddcc0>,
'relates_to': None,
'reply_to_id': None,
'semantic_action': None,
'service_url': 'https://smba.trafficmanager.net/uk/',
'speak': None,
'suggested_actions': None,
'summary': None,
'text': '<at>Bot</at> hello\n',
'text_format': 'plain',
'text_highlights': None,
'timestamp': datetime.datetime(2019, 12, 11, 9, 51, 44, 23987, tzinfo=<isodate.tzinfo.Utc object at 0x7fc33793c668>),
'topic_name': None,
'type': 'message',
'value': None,
'value_type': None}
When I am using turn_context.remove_recipient_mention(turn_context.activity) it raises an error:
(Pdb) turn_context.remove_recipient_mention(turn_context.activity)
*** AttributeError: 'Entity' object has no attribute 'mentioned'
It is because actually mentioned data are under the additional_properties key and remove_mention_text method failed to get it.
botbuilder/core/turn_context.py(316)remove_mention_text()
-> if mention.mentioned.id == identifier:
(Pdb) pp mention
<botbuilder.schema._models_py3.Entity object at 0x7fc3354ddb38>
(Pdb) pp mention.__dict__
{'additional_properties': {'mentioned': {'id': '...',
'name': 'Bot'},
'text': '<at>Bot</at>'},
'type': 'mention'}
Expected behavior
The get_mentions in TurnContext class should parse mentioned taking into account that mentioned data are under additional_properties key:
https://github.com/microsoft/botbuilder-python/blob/master/libraries/botbuilder-core/botbuilder/core/turn_context.py#L375-L381
[bug]