Skip to content

Commit

Permalink
更新models
Browse files Browse the repository at this point in the history
  • Loading branch information
smallevilbeast committed Sep 9, 2022
1 parent 9a0cc00 commit 7a7e927
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
18 changes: 16 additions & 2 deletions fastapi_example/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from functools import wraps
from fastapi import FastAPI
from mgr import ClientManager
from typing import List
from down import get_local_path
from exception import MediaNotExistsError, ClientNotExists
import models
Expand Down Expand Up @@ -243,5 +242,20 @@ async def send_gif(model: models.SendMediaReqModel):
return response_json(1 if ret else 0)


@app.post("/msg/send_xml", summary="发送XML原始消息", tags=["Msg"], response_model=models.ResponseModel)
@catch_exception()
async def send_gif(model: models.SendXmlReqModel):
ret = client_mgr.get_client(model.guid).send_xml(model.to_wxid, model.xml)
return response_json(1 if ret else 0)


@app.post("/msg/send_pat", summary="发送拍一拍", tags=["Msg"], response_model=models.ResponseModel)
@catch_exception()
async def send_gif(model: models.SendPatReqModel):
data = client_mgr.get_client(model.guid).send_pat(model.room_wxid, model.patted_wxid)
return response_json(1, data)



if __name__ == '__main__':
uvicorn.run(app=app)
uvicorn.run(app=app, host='0.0.0.0', port=8000)
10 changes: 10 additions & 0 deletions fastapi_example/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,13 @@ class SendLinkCardReqModel(SendMsgReqModel):
class SendMediaReqModel(SendMsgReqModel):
file_path: Optional[str] = ""
url: Optional[str] = ""


class SendXmlReqModel(SendMsgReqModel):
xml: str


class SendPatReqModel(ClientReqModel):
room_wxid: str
patted_wxid: str

0 comments on commit 7a7e927

Please sign in to comment.