mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
feat: http post quick operation
This commit is contained in:
29
test/quick_action/server.py
Normal file
29
test/quick_action/server.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import uvicorn
|
||||
from fastapi import FastAPI, Request
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
@app.post("/")
|
||||
async def root(request: Request):
|
||||
data = await request.json()
|
||||
print(data)
|
||||
if (data["post_type"] == "message"):
|
||||
text = list(filter(lambda x: x["type"] == "text", data["message"]))[0]["data"]["text"]
|
||||
if text == "禁言":
|
||||
return {"ban": True, "ban_duration": 10}
|
||||
elif text == "踢我":
|
||||
return {"kick": True}
|
||||
elif text == "撤回":
|
||||
return {"delete": True}
|
||||
# print(data["message"])
|
||||
return {"reply": "Hello World"}
|
||||
elif data["post_type"] == "request":
|
||||
if data["request_type"] == "group":
|
||||
return {"approve": False, "reason": "不让你进群"}
|
||||
else:
|
||||
# 加好友
|
||||
return {"approve": True}
|
||||
return {}
|
||||
|
||||
if __name__ == "__main__":
|
||||
uvicorn.run(app, host="", port=8000)
|
Reference in New Issue
Block a user