mirror of
https://github.com/KnugiHK/WhatsApp-Chat-Exporter.git
synced 2026-08-28 23:15:13 +02:00
Support no wa.db
This commit is contained in:
+19
-12
@@ -24,18 +24,19 @@ def determine_day(last, current):
|
|||||||
data = {}
|
data = {}
|
||||||
|
|
||||||
# Get contacts
|
# Get contacts
|
||||||
wa = sqlite3.connect("wa.db")
|
if os.path.isfile("wa.db"):
|
||||||
c = wa.cursor()
|
wa = sqlite3.connect("wa.db")
|
||||||
c.execute("""SELECT count() FROM wa_contacts""")
|
c = wa.cursor()
|
||||||
total_row_number = c.fetchone()[0]
|
c.execute("""SELECT count() FROM wa_contacts""")
|
||||||
print(f"Gathering contacts...({total_row_number})")
|
total_row_number = c.fetchone()[0]
|
||||||
|
print(f"Gathering contacts...({total_row_number})")
|
||||||
|
|
||||||
c.execute("""SELECT jid, display_name FROM wa_contacts; """)
|
c.execute("""SELECT jid, display_name FROM wa_contacts; """)
|
||||||
row = c.fetchone()
|
|
||||||
while row is not None:
|
|
||||||
data[row[0]] = {"name": row[1], "messages":{}}
|
|
||||||
row = c.fetchone()
|
row = c.fetchone()
|
||||||
wa.close()
|
while row is not None:
|
||||||
|
data[row[0]] = {"name": row[1], "messages":{}}
|
||||||
|
row = c.fetchone()
|
||||||
|
wa.close()
|
||||||
|
|
||||||
# Get message history
|
# Get message history
|
||||||
msg = sqlite3.connect("msgstore.db")
|
msg = sqlite3.connect("msgstore.db")
|
||||||
@@ -59,11 +60,17 @@ while content is not None:
|
|||||||
"key_id": content[13]
|
"key_id": content[13]
|
||||||
}
|
}
|
||||||
if "-" in content[0] and content[2] == 0:
|
if "-" in content[0] and content[2] == 0:
|
||||||
|
name = None
|
||||||
if content[8] in data:
|
if content[8] in data:
|
||||||
name = data[content[8]]["name"]
|
name = data[content[8]]["name"]
|
||||||
|
if "@" in content[8]:
|
||||||
|
fallback = content[8].split('@')[0]
|
||||||
|
else:
|
||||||
|
fallback = None
|
||||||
else:
|
else:
|
||||||
name = None
|
fallback = None
|
||||||
data[content[0]]["messages"][content[1]]["sender"] = name or content[8].split('@')[0]
|
|
||||||
|
data[content[0]]["messages"][content[1]]["sender"] = name or fallback
|
||||||
else:
|
else:
|
||||||
data[content[0]]["messages"][content[1]]["sender"] = None
|
data[content[0]]["messages"][content[1]]["sender"] = None
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -111,7 +111,7 @@
|
|||||||
<div style="text-align: right; color:#70777c;">{{ msg.time }}</div>
|
<div style="text-align: right; color:#70777c;">{{ msg.time }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="w3-row">
|
<div class="w3-row">
|
||||||
<div class="w3-col m2 l2"><img src="{{ their_avatar }}"></div>
|
<div class="w3-col m2 l2"><img src="{{ their_avatar }}" onerror="this.style.display='none'"></div>
|
||||||
<div class="w3-col m10 l10">
|
<div class="w3-col m10 l10">
|
||||||
<div style="text-align: left;">
|
<div style="text-align: left;">
|
||||||
{% if msg.reply is not none %}
|
{% if msg.reply is not none %}
|
||||||
|
|||||||
Reference in New Issue
Block a user