-
Notifications
You must be signed in to change notification settings - Fork 3
/
run.py
executable file
·51 lines (49 loc) · 1.71 KB
/
run.py
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
#!/usr/bin/python3
import argparse
import os
import sys
from way2sms import Way2sms
parser = argparse.ArgumentParser()
parser.add_argument('-n', '--number', action='store', dest='contact', help='Contact number file')
parser.add_argument('-t', '--text', action='store', dest='text', help='Text SMS content file')
parser.add_argument('-s', '--sent', action='store', dest='day', help='N day old sent sms')
parser.add_argument('-c', '--check', action='store_true', dest='check', help='Check daily sms limit')
parser.add_argument('-a', '-add', action='store', dest='add', help='Add contact to your address book')
parser.add_argument('-l', '--logout', action="store_true", dest='logout', help='To logout from session')
if len(sys.argv) == 1:
parser.print_help()
sys.exit(1)
results = parser.parse_args()
w = Way2sms()
if results.add:
name = input('Enter Contact name:')
mobile = input('Enter Contact number:')
gender = input('Enter gender')
w.addContact(mobile, name, gender)
if results.logout:
w.logout()
if results.check:
w.checkwebmsgcount()
sys.exit(0)
if results.day:
w.history(results.day)
sys.exit(0)
if not results.contact and results.text:
print('Please provide mobile number!')
sys.exit(1)
if not results.text and results.contact:
print('Please provide Text sms content!')
sys.exit(1)
text = ''
mobile_numbers = []
if os.path.isfile(results.contact):
contact_file = open(results.contact)
mobile_numbers = [mobile.strip() for mobile in contact_file]
else:
mobile_numbers = str(results.contact).split(',')
if os.path.isfile(results.text):
text = open(results.text).read()
else:
text = results.text
print(mobile_numbers, text)
w.sms(mobile=mobile_numbers, text=text)