-
Notifications
You must be signed in to change notification settings - Fork 0
/
SwitchboardServer.py
49 lines (43 loc) · 1.27 KB
/
SwitchboardServer.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
import socket
from Util import *
from Backend import *
import MSNSession
def SB_USR(conn,data,conninfo,raw):
cmdarg = data.split(' ')
sync, email, key = cmdarg[1],cmdarg[2],cmdarg[3]
userdata = MSNSession.ReadKey(int(key))
if userdata == None:
senderror(conn,sync,911)
return 2
email, nickname = userdata['email'], userdata['nickname']
conninfo["email"] = email
MSNSession.CreateSBsession(conn,"")
conninfo["cmdwlist"] = []
safesend(conn, f"USR {sync} OK {email} {nickname}")
def SB_CAL(conn,data,conninfo,raw):
cmdarg = data.split(' ')
sync = cmdarg[1]
callemail = cmdarg[2]
calluserinfo = GetUserInfoByEmail(callemail)
conninfo["discordid"] = calluserinfo['discordid']
MSNSession.ChangeSBsession(conn,calluserinfo['discordid'])
safesend(conn, f"CAL {sync} RINGING 1337")
safesend(conn, f"JOI {callemail} {calluserinfo['nickname']}")
def SB_MSG(conn,data,conninfo,raw):
raw = raw.decode('utf-8')
cmdarg = raw.split(' ')
sync = cmdarg[1]
ack = cmdarg[2]
msglen = cmdarg[3]
headers,msg = ParseMessage(raw)
print(headers)
if "text/plain" in headers["Content-Type"]:
if msg != "\r\n":
OnMSGRecieve(conn,msg,conninfo)
return 0 #stub
def SB_OUT(conn,data,conninfo,raw):
return 2
SB_cmds = {"USR": SB_USR,
"CAL": SB_CAL,
"MSG": SB_MSG,
"OUT": SB_OUT}