Skip to content

Commit

Permalink
telegram fix: reactions datastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
dale-wahl committed Jul 22, 2024
1 parent 1c0bf5e commit 2c8c860
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion datasources/telegram/search_telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,14 @@ def map_item(message):

if message.get("reactions") and message["reactions"].get("results"):
for reaction in message["reactions"]["results"]:
reactions += reaction["reaction"] * reaction["count"]
if type(reaction["reaction"]) is dict and "emoticon" in reaction["reaction"]:
# Updated to support new reaction datastructure
reactions += reaction["reaction"]["emoticon"] * reaction["count"]
elif type(reaction["reaction"]) is str and "count" in reaction:
reactions += reaction["reaction"] * reaction["count"]
else:
# Failsafe; can be updated to support formatting of new datastructures in the future
reactions += f"{reaction}, "

return MappedItem({
"id": f"{message['_chat']['username']}-{message['id']}",
Expand Down

0 comments on commit 2c8c860

Please sign in to comment.