-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_contact.py
More file actions
100 lines (78 loc) · 2.91 KB
/
add_contact.py
File metadata and controls
100 lines (78 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env python3
"""
Helper script to add new contacts to contacts.csv while the main script is running
"""
import csv
import os
def add_contact():
"""Add a new contact to the CSV file (new template format)"""
print("📱 Add New Contact - HIGH-VOLUME MODE")
print("=" * 50)
print("💡 Template message: All contacts get the same message & attachment")
print("📝 You only need to provide the phone number")
print("=" * 50)
# Get phone number only
phone = input("📞 Phone number (with country code, e.g., +1234567890): ").strip()
if not phone:
print("❌ Phone number is required!")
return
# Ensure phone number has + prefix
if not phone.startswith('+'):
phone = '+' + phone
# Check if CSV exists
csv_file = "contacts.csv"
file_exists = os.path.exists(csv_file)
# Add to CSV
with open(csv_file, 'a', newline='', encoding='utf-8') as f:
writer = csv.writer(f)
# Write header if file is new
if not file_exists:
writer.writerow(['PhoneNumber'])
# Write contact (just phone number)
writer.writerow([phone])
print(f"✅ Contact added: {phone}")
print("💡 Will receive template message & attachment")
print("🚀 Main script will process in next cycle (30 seconds)!")
def view_contacts():
"""View current contacts in the CSV file (new template format)"""
csv_file = "contacts.csv"
if not os.path.exists(csv_file):
print("❌ No contacts.csv file found!")
return
print("📋 Current Contacts - HIGH-VOLUME MODE")
print("=" * 50)
print("💡 All contacts will receive the same template message & attachment")
print("=" * 50)
with open(csv_file, 'r', encoding='utf-8') as f:
reader = csv.DictReader(f)
contacts = list(reader)
if not contacts:
print("📭 No contacts found")
return
print(f"📱 Total contacts: {len(contacts)}")
print("📞 Phone numbers:")
for i, row in enumerate(contacts, 1):
phone = row.get('PhoneNumber', 'N/A')
print(f" {i}. {phone}")
print(f"\n📝 Template message: All will receive the same message")
print(f"📎 Template attachment: All will receive the same attachment")
def main():
"""Main menu"""
while True:
print("\n🚀 WhatsApp Bulk Sender - Contact Manager")
print("=" * 50)
print("1. 📱 Add new contact")
print("2. 📋 View current contacts")
print("3. 🚪 Exit")
choice = input("\nChoose an option (1-3): ").strip()
if choice == '1':
add_contact()
elif choice == '2':
view_contacts()
elif choice == '3':
print("👋 Goodbye!")
break
else:
print("❌ Invalid choice! Please enter 1, 2, or 3.")
if __name__ == "__main__":
main()