diff --git a/app/__pycache__/main.cpython-310.pyc b/app/__pycache__/main.cpython-310.pyc index 0961716..a85a2cf 100644 Binary files a/app/__pycache__/main.cpython-310.pyc and b/app/__pycache__/main.cpython-310.pyc differ diff --git a/app/main.py b/app/main.py index ea4f1d3..b3cebd2 100644 --- a/app/main.py +++ b/app/main.py @@ -12,6 +12,9 @@ import qrcode import os from fastapi.responses import FileResponse from fastapi.staticfiles import StaticFiles +from app.tgMesaage import sendTg #发送tg消息 +from datetime import datetime + # 初始化数据库 models.Base.metadata.create_all(bind=engine) @@ -53,6 +56,25 @@ def hello(): response = f"你好,\n..........................\n一名开发者\n副业:跨境电商\n#公众号:异度世界\n..........................\n回复关键词,了解更多:\n1. 微信机器人\n2. 数字游民\n3. 加群\n..........................\n[该消息是接受好友自动回复]" return PlainTextResponse(content=response) +@app.get("/tgMessage") +def tgMessage(openid: Optional[str] = None,db: Session = Depends(get_db)): + current_time = datetime.now() + print("Current Date and Time:", current_time) + # 发送tg消息通知 wxid_4413224132412 || o7LFAwR32hWGq9XOpd7ZxK1wZxq8 + + openid="o7LFAwR32hWGq9XOpd7ZxK1wZxq82" + print('openid',openid) + if openid: + # 查询用户信息:昵称 + userInfo=read_user(openid,db=db) + if userInfo: + print('userInfo==>',userInfo) + message=f'{userInfo.nickname}/{userInfo.gender}在{current_time}进行了访问' + sendTg(message) + else: + print('openid未关联,在') + message=f'openid: {openid}-未关联,在{current_time}访问网页' + sendTg(message) def create_user_task(db: Session, user: schemas.UserCreate): try: @@ -104,7 +126,8 @@ def read_users(skip: int = 0, limit: int = 10, db: Session = Depends(get_db)): def read_user(identifier: str, db: Session = Depends(get_db)): user = crud.get_user_by_openid_or_wxid(db, identifier=identifier) if user is None: - raise HTTPException(status_code=404, detail="User not found") + # raise HTTPException(status_code=404, detail="User not found") + print('查询用户不存在') return user @@ -134,7 +157,8 @@ def generate_qr(wxid: Optional[str] = Query(None), db: Session = Depends(get_db) - url = "https://web.hackrobot.cn" + # url = "https://web.hackrobot.cn" + url="http://192.168.31.219:10086" if wxid: url += f"?wxid={wxid}" diff --git a/images/combined_wxid_4413224132412.jpg b/images/combined_wxid_4413224132412.jpg index 1f26f4f..10bd2d9 100644 Binary files a/images/combined_wxid_4413224132412.jpg and b/images/combined_wxid_4413224132412.jpg differ