♻️ QQBot for 31-4
This commit is contained in:
parent
3dd2967dce
commit
09d4c500ad
1 changed files with 44 additions and 0 deletions
44
qqbot/31-4/bot.py
Executable file
44
qqbot/31-4/bot.py
Executable file
|
@ -0,0 +1,44 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# # -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from bottle import post, run, request, static_file, route
|
||||||
|
|
||||||
|
sys.path.append("../../data/convert/31-4")
|
||||||
|
from db import *
|
||||||
|
|
||||||
|
db.bind(provider="sqlite", filename="../../data/clean/31-4/data.sqlite3")
|
||||||
|
db.generate_mapping()
|
||||||
|
|
||||||
|
|
||||||
|
@route("/pics/<filepath:path>")
|
||||||
|
def server_static(filepath):
|
||||||
|
return static_file(filepath, root="../../data/render/31-4/output")
|
||||||
|
|
||||||
|
|
||||||
|
@post("/")
|
||||||
|
def recv_msg():
|
||||||
|
data = request.json
|
||||||
|
if (
|
||||||
|
data["post_type"] == "message"
|
||||||
|
and data["message_type"] == "group"
|
||||||
|
and data["group_id"] in [346058845, 512621194]
|
||||||
|
):
|
||||||
|
name = data["raw_message"]
|
||||||
|
with db_session:
|
||||||
|
query = select(m for m in Melee if m.name == name)
|
||||||
|
if query.count() == 0:
|
||||||
|
query = select(m for m in Shield if m.name == name)
|
||||||
|
if query.count() == 0:
|
||||||
|
query = select(m for m in Ranged if m.name == name)
|
||||||
|
if query.count() == 0:
|
||||||
|
query = Outfit.select(name=name)
|
||||||
|
if query.count() > 0:
|
||||||
|
return {
|
||||||
|
"reply": f"[CQ:image,file=http://localhost:7000/pics/{name}.png,cache=0]",
|
||||||
|
"at_sender": False,
|
||||||
|
}
|
||||||
|
return "OK"
|
||||||
|
|
||||||
|
|
||||||
|
run(host="localhost", port=7000)
|
Loading…
Reference in a new issue