This commit is contained in:
hackrobot
2024-07-17 22:44:57 +08:00
parent a2ed0966d0
commit 1ad9dfc8da
2 changed files with 7 additions and 6 deletions

View File

@@ -12,7 +12,7 @@ import qrcode
import os
from fastapi.responses import FileResponse
from fastapi.staticfiles import StaticFiles
from app import tgMessage # type: ignore #发送tg消息
# from app import tgMessage # type: ignore #发送tg消息
from datetime import datetime
# 初始化数据库
@@ -69,20 +69,21 @@ def tgMessagefun(openid: Optional[str] = None, db: Session = Depends(get_db)):
if openid:
# 查询用户信息:昵称
data = read_user(openid, db=db)
print('data==>', data)
# print('data==>', data)
userInfo = data['userInfo']
print('userInfo==>', userInfo)
# print('userInfo==>', userInfo)
if userInfo:
# print('userInfo==>', userInfo)
# message = f"{userInfo['nickname']}/{userInfo['gender']}在{current_time}进行了访问"
message = f"{userInfo.nickname}/{userInfo.gender}{current_time}进行了访问"
print(message)
tgMessage.sendTg(message)
# tgMessage.sendTg(message)
else:
print('openid未关联')
message = f'openid: {openid}-未关联,在{current_time}访问网页'
tgMessage.sendTg(message)
print(message)
# tgMessage.sendTg(message)
def create_user_task(db: Session, user: schemas.UserCreate):