mirror of
https://github.com/KnugiHK/WhatsApp-Chat-Exporter.git
synced 2026-04-27 08:21:33 +00:00
Rename the obj variable to json_obj in telegram_json_format
This commit is contained in:
@@ -674,34 +674,35 @@ def telegram_json_format(jik: str, data: Dict, timezone_offset) -> Dict:
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
# not a real chat: e.g. statusbroadcast
|
# not a real chat: e.g. statusbroadcast
|
||||||
chat_id = 0
|
chat_id = 0
|
||||||
obj = {
|
json_obj = {
|
||||||
"name": data["name"] if data["name"] else jik,
|
"name": data["name"] if data["name"] else jik,
|
||||||
"type": get_chat_type(jik),
|
"type": get_chat_type(jik),
|
||||||
"id": chat_id,
|
"id": chat_id,
|
||||||
"messages": [ {
|
"messages": [ {
|
||||||
"id": int(msgId),
|
"id": int(msgId),
|
||||||
"type": "message",
|
"type": "message",
|
||||||
"date": timing.format_timestamp(msg["timestamp"], "%Y-%m-%dT%H:%M:%S"),
|
"date": timing.format_timestamp(msg["timestamp"], "%Y-%m-%dT%H:%M:%S"),
|
||||||
"date_unixtime": int(msg["timestamp"]),
|
"date_unixtime": int(msg["timestamp"]),
|
||||||
"from": get_from_string(msg, chat_id),
|
"from": get_from_string(msg, chat_id),
|
||||||
"from_id": get_from_id(msg, chat_id),
|
"from_id": get_from_id(msg, chat_id),
|
||||||
"reply_to_message_id": get_reply_id(data, msg["reply"]),
|
"reply_to_message_id": get_reply_id(data, msg["reply"]),
|
||||||
"text": msg["data"],
|
"text": msg["data"],
|
||||||
"text_entities": [
|
"text_entities": [
|
||||||
{
|
{
|
||||||
# TODO this will lose formatting and different types
|
# TODO this will lose formatting and different types
|
||||||
"type": "plain",
|
"type": "plain",
|
||||||
"text": msg["data"],
|
"text": msg["data"],
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
} for msgId, msg in data["messages"].items()]
|
|
||||||
}
|
}
|
||||||
|
for msgId, msg in data["messages"].items()]
|
||||||
|
}
|
||||||
# remove empty messages and replies
|
# remove empty messages and replies
|
||||||
for msg_id, msg in enumerate(obj["messages"]):
|
for msg_id, msg in enumerate(json_obj["messages"]):
|
||||||
if not msg["reply_to_message_id"]:
|
if not msg["reply_to_message_id"]:
|
||||||
del obj["messages"][msg_id]["reply_to_message_id"]
|
del json_obj["messages"][msg_id]["reply_to_message_id"]
|
||||||
obj["messages"] = [m for m in obj["messages"] if m["text"]]
|
json_obj["messages"] = [m for m in json_obj["messages"] if m["text"]]
|
||||||
return obj
|
return json_obj
|
||||||
|
|
||||||
|
|
||||||
class WhatsAppIdentifier(StrEnum):
|
class WhatsAppIdentifier(StrEnum):
|
||||||
|
|||||||
Reference in New Issue
Block a user