2022-05-28 23:26:30 +00:00
|
|
|
from files.__main__ import app, limiter
|
|
|
|
from files.helpers.wrappers import *
|
|
|
|
from files.helpers.alerts import *
|
|
|
|
from files.helpers.get import *
|
|
|
|
from files.helpers.const import *
|
2022-05-30 01:43:16 +00:00
|
|
|
from files.helpers.wrappers import *
|
2022-05-29 03:33:44 +00:00
|
|
|
from files.helpers.lottery import *
|
2022-05-29 00:02:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
@app.post("/lottery/end")
|
2022-05-30 01:43:16 +00:00
|
|
|
@admin_level_required(3)
|
|
|
|
@lottery_required
|
2022-05-29 00:02:35 +00:00
|
|
|
def lottery_end(v):
|
2022-05-30 03:12:13 +00:00
|
|
|
success, message = end_lottery_session()
|
|
|
|
return {"message": message} if success else {"error": message}
|
2022-05-29 00:02:35 +00:00
|
|
|
|
2022-05-29 03:33:44 +00:00
|
|
|
|
|
|
|
@app.post("/lottery/start")
|
2022-05-30 01:43:16 +00:00
|
|
|
@admin_level_required(3)
|
|
|
|
@lottery_required
|
2022-05-29 03:33:44 +00:00
|
|
|
def lottery_start(v):
|
2022-05-30 03:12:13 +00:00
|
|
|
start_new_lottery_session()
|
|
|
|
return {"message": "Lottery started."}
|
2022-05-29 00:02:35 +00:00
|
|
|
|
|
|
|
|
2022-05-28 23:26:30 +00:00
|
|
|
@app.post("/lottery/buy")
|
2022-05-30 04:31:48 +00:00
|
|
|
@limiter.limit("3/second;100/minute;500/hour;1000/day")
|
2022-05-28 23:26:30 +00:00
|
|
|
@auth_required
|
2022-05-30 01:43:16 +00:00
|
|
|
@lottery_required
|
2022-05-28 23:26:30 +00:00
|
|
|
def lottery_buy(v):
|
2022-05-30 00:49:14 +00:00
|
|
|
success, message = purchase_lottery_ticket(v)
|
|
|
|
lottery, participants = get_active_lottery_stats()
|
2022-05-29 00:02:35 +00:00
|
|
|
|
2022-05-29 03:33:44 +00:00
|
|
|
if success:
|
2022-05-29 06:06:39 +00:00
|
|
|
return {"message": message, "stats": {"user": v.lottery_stats, "lottery": lottery, "participants": participants}}
|
2022-05-29 03:33:44 +00:00
|
|
|
else:
|
2022-05-29 06:06:39 +00:00
|
|
|
return {"error": message, "stats": {"user": v.lottery_stats, "lottery": lottery, "participants": participants}}
|
2022-05-28 23:26:30 +00:00
|
|
|
|
2022-05-29 00:02:35 +00:00
|
|
|
|
2022-05-29 03:33:44 +00:00
|
|
|
@app.get("/lottery/active")
|
2022-05-30 04:31:48 +00:00
|
|
|
@limiter.limit("3/second;100/minute;500/hour;1000/day")
|
2022-05-29 00:02:35 +00:00
|
|
|
@auth_required
|
2022-05-30 01:43:16 +00:00
|
|
|
@lottery_required
|
2022-05-29 03:33:44 +00:00
|
|
|
def lottery_active(v):
|
2022-05-30 00:49:14 +00:00
|
|
|
lottery, participants = get_active_lottery_stats()
|
|
|
|
|
2022-05-29 06:01:45 +00:00
|
|
|
return {"message": "", "stats": {"user": v.lottery_stats, "lottery": lottery, "participants": participants}}
|