forked from aarnhub/python-sms-sender
-
Notifications
You must be signed in to change notification settings - Fork 0
/
smser.py
218 lines (204 loc) · 7.28 KB
/
smser.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
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
import pickle
import os
import urllib
import urllib.parse
import urllib.request
import time
import ssl
import sys
def main():
print("\033[H\033[J")
mainmenu()
def mainmenu():
if not os.path.exists('smssenderdb.pickle'):
print("1 STEP => SETUP API SETTINGS")
choicest1 = input("""\033[1;32m
(`|\/|(` (`[~|\ ||\[~|)
_)| |_) _)[_| \||/[_|\
\033[1;0m
=== main menu ====
\033[1;33m
1. Single SMS:
2. Bulk SMS:
3. API Settings:
4. Exit: \033[1;0m
Please enter your choice [1-4]: """)
if choicest1 == "1":
print("\033[H\033[J")
singlesms()
elif choicest1 == "2":
bulksms()
elif choicest1 == "3":
print("\033[H\033[J")
apisettings()
elif choicest1 == "4":
print(" Bye Bye! :)")
pass
else:
print("\033[H\033[J")
print("You must only select either [1-4]")
print("Please try again")
mainmenu()
def apisettings():
choicest = input("""\033[1;32m
(`|\/|(` (`[~|\ ||\[~|)
_)| |_) _)[_| \||/[_|\
\033[1;0m
=== = Proovl.com API Settings ===
\033[1;33m
1. Update Settings:
2. Go Back:\033[1;0m
Please enter your choice [1-2]: """)
if choicest == "1":
input_number = input(" \033[1;32m1.Enter Proovl.com Phone number\033[1;0m\n")
input_userid = input(" \033[1;32m2.Enter Proovl.com UserID\033[1;0m\n")
input_token = input(" \033[1;32m3.Enter Proovl.com Token\033[1;0m\n")
try:
with open('smssenderdb.pickle', 'wb') as wfp:
pickle.dump((input_number, input_userid, input_token), wfp, protocol=pickle.HIGHEST_PROTOCOL)
print("\033[H\033[J")
print("=== Saved! Current data: ===")
with open('smssenderdb.pickle', 'rb') as rfp:
otput = pickle.load(rfp)
print("\033[1;33m=== Number: " + otput[0] + "\033[1;0m")
print("\033[1;33m=== UserID: " + otput[1] + "\033[1;0m")
print("\033[1;33m=== Token: " + otput[2] + "\033[1;0m")
except:
print("Something wrong. Check files permissions.")
finally:
mainmenu()
return
elif choicest == "2":
print("\033[H\033[J")
mainmenu()
else:
print("\033[H\033[J")
print("You must only select either [1-2]")
print("Please try again")
apisettings()
def singlesms():
print ("""\033[1;32m
(`|\/|(` (`[~|\ ||\[~|)
_)| |_) _)[_| \||/[_|\
\033[1;0m
""")
try:
with open('smssenderdb.pickle', 'rb') as rfp:
otput = pickle.load(rfp)
from2 = otput[0]
user1 = otput[1]
token1 = otput[2]
except:
print("\033[1;33mAfter sending, please check Api settings. It can't be empty \033[1;0m")
from2 = "44555555555"
user1 = "Empty"
token1 = "Empty"
finally:
user = user1 # change ***** to your Proovl user ID
token = token1 # change ***** to your Proovl token
from_n = from2 # change ***** to your Proovl SMS number
print("\033[1;33mSettings SID:" + from_n + " UID:" + user + " token:" + token + "\033[1;0m")
# to = "**********" # change ***** to receiver number
# text = "**********"
input_var1 = input("Enter Phone number (with country code) and press Enter:\n")
input_var2 = input("Enter Text and press Enter:\n: ")
print ("You entered Number: " + "\033[1;32m" + input_var1 + "\033[1;0m")
print ("You entered Text: " + "\033[1;32m" + input_var2 + "\033[1;0m")
url = "https://www.proovl.com/api/send.php?"
hdr = { 'User-Agent' : 'Mozilla/5.0 (Windows NT 6.1; Win64; x64)' }
params = {
"user": user,
"token": token,
"from": from_n,
"to": input_var1,
"text": input_var2}
try:
_create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
pass
else:
ssl._create_default_https_context = _create_unverified_https_context
query_string = urllib.parse.urlencode(params)
http_req = url + query_string
req = urllib.request.Request(http_req, headers=hdr)
f = urllib.request.urlopen(req)
txt = (f.read().decode('utf-8'))
x = txt.split(";")
g = x[1].replace("\"","")
y = x[0].replace("\"","")
if x[0] == "Error":
print("\033[1;31m[Error message]\033[1;0m",x[1])
else:
print("\033[1;32m[Message has been sent!]\033[1;0m ID:",x[1])
f.close()
if input("Send new message? \033[1;32m(Y/N)\033[1;0m").strip().upper() != 'Y':
print("\033[H\033[J")
mainmenu()
return
else:
print("\033[H\033[J")
singlesms()
def bulksms():
print("\033[H\033[J")
print (""" \033[1;32m
(`|\/|(` (`[~|\ ||\[~|)
_)| |_) _)[_| \||/[_|\
\033[1;0m
""")
try:
with open('smssenderdb.pickle', 'rb') as rfp:
otput = pickle.load(rfp)
from2 = otput[0]
user1 = otput[1]
token1 = otput[2]
except:
print("\033[1;33mAfter sending, please check Api settings. It can't be empty \033[1;0m")
from2 = "44555555555"
user1 = "Empty"
token1 = "Empty"
finally:
user = user1 # change ***** to your Proovl user ID
token = token1 # change ***** to your Proovl token
from1 = from2 # change ***** to your Proovl SMS number
print("\033[1;33mSettings SID:" + from1 + " UID:" + user + " token:" + token + "\033[1;0m")
int_string = input("Enter phone numbers, separated by comma: \n")
input_string2 = input("Enter Text and press Enter: \n")
numbers = int_string.split(",")
messagesSent = 0
host = "https://www.proovl.com/api/send.php?"
hdr = { 'User-Agent' : 'Mozilla/5.0 (Windows NT 6.1; Win64; x64)' }
for x in numbers:
messagesSent += 1
params = {
"user": user,
"token": token,
"from": from1,
"text": input_string2,
"to": x}
try:
_create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
pass
else:
ssl._create_default_https_context = _create_unverified_https_context
query_string = urllib.parse.urlencode(params)
http_req = host + query_string
req = urllib.request.Request(http_req, headers=hdr)
f = urllib.request.urlopen(req)
txt = (f.read().decode('utf-8'))
z = txt.split(";")
time.sleep(0.5)
print("\033[1;32mProgress: {}/{}\033[1;0m".format(messagesSent, len(numbers)), (x),("" + z[1] + ""))
if z[0] == "Error":
print("\033[1;31m== Error. Text messages not sent ==\033[1;0m")
else:
print("\033[1;32m== All messages has been sent! ==\033[1;0m")
f.close()
if input("Send new message? \033[1;32m(Y/N)\033[1;0m").strip().upper() != 'Y':
print("\033[H\033[J")
mainmenu()
return
else:
print("\033[H\033[J")
bulksms()
main()