This repository was archived by the owner on Sep 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
43 lines (38 loc) · 1.38 KB
/
app.py
File metadata and controls
43 lines (38 loc) · 1.38 KB
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
from winter_db import *
from wreck_winter_challenge import WreckAWinter
from slack_api import *
from time import sleep
import json
from flask import Flask, request, jsonify, make_response
app = Flask(__name__)
@app.route('/', methods=['POST'])
def webhook():
print("event received")
GYM_POINTS = 1.0
THROW_POINTS = 1.0
CARDIO_POINTS = 0.5
CHALLENGE_POINTS = 1.5
BOT_CHANNEL = "CBJAJPZ8B"
data = request.get_json()
if data['type'] == "url_verification":
return jsonify({'challenge': data['challenge']})
print('HTTP_X_SLACK_RETRY_NUM' in list(request.__dict__['environ'].keys()))
if 'HTTP_X_SLACK_RETRY_NUM' in list(request.__dict__['environ'].keys()):
print("Retry Number " + request.__dict__['environ']['HTTP_X_SLACK_RETRY_NUM'])
if int(request.__dict__['environ']['HTTP_X_SLACK_RETRY_NUM']):
return make_response("Ok", 200, )
print(data)
obj = WreckAWinter(data)
if not obj._bot and not obj._reaction_added and not obj._reaction_removed:
print("not a bot")
obj.isRepeat()
obj._repeat = False
if obj._points_to_add > 0:
print("points to add")
obj.handle_db()
else:
print("executing commands")
obj.execute_commands()
print(obj)
print("responding")
return make_response("Ok", 200, )