Show different warning messages when enrich_from_vcards is set and contact db is empty

This commit is contained in:
KnugiHK
2025-02-20 23:46:26 +08:00
parent db577c8de6
commit 8c85656831
2 changed files with 6 additions and 3 deletions

View File

@@ -472,7 +472,7 @@ def main():
if os.path.isfile(contact_db):
with sqlite3.connect(contact_db) as db:
db.row_factory = sqlite3.Row
contacts(db, data)
contacts(db, data, args.enrich_from_vcards)
elif args.ios:
contacts = ios_handler.contacts
messages = ios_handler.messages

View File

@@ -153,13 +153,16 @@ def decrypt_backup(database, key, output, crypt=Crypt.CRYPT14, show_crypt15=Fals
raise ValueError("The plaintext is not a SQLite database. Did you use the key to encrypt something...")
def contacts(db, data):
def contacts(db, data, enrich_from_vcards):
# Get contacts
c = db.cursor()
c.execute("""SELECT count() FROM wa_contacts""")
total_row_number = c.fetchone()[0]
if total_row_number == 0:
print("No contacts profiles found in the default database, consider using --enrich-from-vcards for adopting names from exported contacts from Google")
if enrich_from_vcards is not None:
print("No contacts profiles found in the default database, contacts will be imported from the specified vCard file.")
else:
print("No contacts profiles found in the default database, consider using --enrich-from-vcards for adopting names from exported contacts from Google")
return False
else:
print(f"Processing contacts...({total_row_number})")