-
Notifications
You must be signed in to change notification settings - Fork 0
/
sender.py
executable file
·41 lines (33 loc) · 1.01 KB
/
sender.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
#!/usr/bin/env python3
from ii_functions import *
from getcfg import *
import network
import urllib.parse
import paths
def sendMessages(proxy=None, error_callback=None):
countsent=0
for server in servers:
namespace = server["outbox_storage_id"]
storage_path = os.path.join(paths.tossesdir, namespace)
files = scanForTosses(storage_path)
if len(files) == 0:
continue
adress=server["adress"]
authstr=server["authstr"]
for file in files:
toss_path = os.path.join(storage_path, file + ".toss")
f=read_file(toss_path)
code=base64.b64encode(bytes(f, "utf8"))
params = {'tmsg': code,'pauth': authstr}
data = urllib.parse.urlencode(params).encode("utf8")
print(adress)
out = network.getfile(adress + 'u/point', proxy, data)
print(out)
if out.startswith('msg ok'):
countsent+=1
one=os.path.join(storage_path, file+".toss")
two=os.path.join(storage_path, file+".out")
os.rename(one, two)
elif (error_callback != None):
error_callback(toss_path, out)
return countsent