2022-09-29 01:29:45 -05:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# # -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import sys
|
|
|
|
from bottle import post, run, request, static_file, route
|
|
|
|
|
2022-09-30 07:53:40 -05:00
|
|
|
sys.path.append("../../data/convert/31-2")
|
2022-09-29 01:29:45 -05:00
|
|
|
from db import *
|
|
|
|
|
2022-09-30 07:53:40 -05:00
|
|
|
db.bind(provider="sqlite", filename="../../data/clean/31-2/data.sqlite3")
|
2022-09-29 01:29:45 -05:00
|
|
|
db.generate_mapping()
|
|
|
|
|
|
|
|
|
|
|
|
@route("/pics/<filepath:path>")
|
|
|
|
def server_static(filepath):
|
2022-09-30 08:29:10 -05:00
|
|
|
return static_file(filepath, root="../../data/render/31-2/output")
|
2022-09-29 01:29:45 -05:00
|
|
|
|
|
|
|
|
|
|
|
@post("/")
|
|
|
|
def recv_msg():
|
|
|
|
data = request.json
|
|
|
|
if (
|
|
|
|
data["post_type"] == "message"
|
|
|
|
and data["message_type"] == "group"
|
2022-09-30 08:29:10 -05:00
|
|
|
and data["group_id"] in [346058845, 512621194]
|
2022-09-29 01:29:45 -05:00
|
|
|
):
|
|
|
|
name = data["raw_message"]
|
2022-09-29 01:33:48 -05:00
|
|
|
with db_session:
|
|
|
|
query = select(m for m in Melee if m.name == name)
|
2022-09-30 08:29:10 -05:00
|
|
|
if query.count() == 0:
|
|
|
|
query = select(m for m in Shield if m.name == name)
|
2022-10-03 04:35:17 -05:00
|
|
|
if query.count() == 0:
|
|
|
|
query = select(m for m in Ranged if m.name == name)
|
2022-10-06 22:37:25 -05:00
|
|
|
if query.count() == 0:
|
|
|
|
query = Outfit.select(name=name)
|
2022-09-29 01:33:48 -05:00
|
|
|
if query.count() > 0:
|
|
|
|
return {
|
2022-09-30 08:29:10 -05:00
|
|
|
"reply": f"[CQ:image,file=http://localhost:7000/pics/{name}.png,cache=0]",
|
2022-09-29 01:33:48 -05:00
|
|
|
"at_sender": False,
|
|
|
|
}
|
2022-09-29 01:29:45 -05:00
|
|
|
return "OK"
|
|
|
|
|
|
|
|
|
|
|
|
run(host="localhost", port=7000)
|