-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
30 lines (25 loc) · 853 Bytes
/
app.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
from flask import Flask, request, json
from settings import confirmation_token,secret
import vk, bot
import random
app = Flask(__name__)
@app.route('/')
def hello():
return 'Hello'
@app.route('/', methods=['POST'])
def processing():
data = json.loads(request.data)
print(data)
if 'type' not in data.keys():
return 'not vk'
if 'secret' in data.keys():
if data['secret']==secret:
if data['type']=='confirmation':
return confirmation_token
elif data['type']=='message_new':
user_id = data['object']['from_id']
user_message = data['object']['text']
bot.message_processing(user_id=user_id, user_message=user_message.lower())
return 'ok'
if __name__ == "__main__":
app.run(host= '0.0.0.0', port = '80')