forked from spaceforinception/dost
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainServer.py
92 lines (60 loc) · 1.75 KB
/
mainServer.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
from flask import Flask,request
from twilio.twiml.messaging_response import MessagingResponse
from messages import shortMenu, MainMenu, ErrorReply, introPage, n
from wiki import wiki
from covid import covid
from video import video, download_video
from sender import sendMessage
from lyrics import getLyrics
from news import news
from time import sleep
def menu(nothing:str=''):
return shortMenu
def longMenu(nothing:str=''):
return MainMenu
def error(nothing:str=''):
return ErrorReply
validInputs = {
"help":menu,
"info":menu,
"help-all":longMenu,
"wiki":wiki,
"video":video,
"covid":covid,
"news":news,
"youtube":video,
"dvideo":download_video,
"lyrics":getLyrics,
"error":error
}
################################################################################
################################################################################
app = Flask(__name__)
@app.route("/")
def hello():
return introPage
@app.route("/sms", methods=['POST'])
def main():
From = request.form.get('From')[9:]
msg = request.form.get('Body').lower().split()
if len(msg) == 1:
arg = ''
elif len(msg) == 2:
arg = msg[1]
else:
arg = msg[1:]
msg = msg[0]
if msg in validInputs:
msg = validInputs[msg](arg)
else:
msg = validInputs["error"]()
if isinstance(msg, list):
msg = "\n\n".join(msg)
msg += "\n\nType help for more options."
sendMessage(clientPhoneNo=From, msg=msg)
return str(msg)
################################################################################
################################################################################
if __name__ == "__main__":
app.run(debug=True)
# app.run()