Validate message before trying to demunge (#1427)

The data field of the message sent to the event handler may not always be a dictionary, (Example case Timer skill, which sets data to the timer name)

This validates the message type and the type of the data field before trying to unmunge.
pull/1428/head
Åke 2018-02-15 21:11:21 +01:00 committed by Steve Penrod
parent ead38602cb
commit b4c6f63352
1 changed files with 5 additions and 3 deletions

View File

@ -69,9 +69,11 @@ def unmunge_message(message, skill_id):
Returns:
Message without clear keywords
"""
for key in message.data:
new_key = key.replace(to_letters(skill_id), '')
message.data[new_key] = message.data.pop(key)
if isinstance(message, Message) and isinstance(message.data, dict):
for key in message.data:
new_key = key.replace(to_letters(skill_id), '')
message.data[new_key] = message.data.pop(key)
return message