diff --git a/.env b/.env index 09a4d0f..49eff22 100644 --- a/.env +++ b/.env @@ -50,3 +50,6 @@ log_level = "INFO" log_days = 10 # 文件缓存天数,为0则不清理缓存,每天凌晨清理 cache_days = 3 + + +push_plus_token = "" diff --git a/.gitignore b/.gitignore index 6f27cba..aa408e2 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,6 @@ __pycache__/ # C extensions *.so - # Distribution / packaging .Python build/ @@ -108,7 +107,7 @@ venv/ ENV/ env.bak/ venv.bak/ - +.env # Spyder project settings .spyderproject .spyproject diff --git a/wechatbot_client/action_manager/manager.py b/wechatbot_client/action_manager/manager.py index 41a18ad..8470df7 100644 --- a/wechatbot_client/action_manager/manager.py +++ b/wechatbot_client/action_manager/manager.py @@ -4,7 +4,7 @@ from pathlib import Path from sys import exit from typing import Callable, Literal, Optional, ParamSpec, TypeVar, Union - +import requests from pydantic import BaseModel from wechatbot_client.com_wechat import ComWechatApi @@ -89,15 +89,40 @@ def init(self, file_manager: FileManager, config: Config) -> None: exit(0) log("SUCCESS", "登录完成...") + + def push(self,config: Config): + headers = { + 'Accept': '*/*', + 'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6', + 'Cache-Control': 'no-cache', + 'Connection': 'keep-alive', + 'Content-Type': 'application/json;charset=UTF-8', + } + json_data = { + 'token': config.push_plus_token, + 'title': '微信登录', + 'content': '快去登录!!', + 'template': 'html', + 'channel': 'wechat', + 'webhook': '', + } + + requests.post('https://www.pushplus.plus/api/send', headers=headers, json=json_data) + + def wait_for_login(self) -> bool: """ 等待登录 """ + count =0 while True: try: if self.com_api.is_wechat_login(): return True time.sleep(1) + count += count + if count % 300 == 0: + self.push(Config) except KeyboardInterrupt: return False @@ -613,7 +638,8 @@ async def upload_file( ) if isinstance(data, str): data = b64decode(data) - file_id = await self.file_manager.cache_file_id_from_data(data, name) + new_image_data = b64decode(data) + file_id = await self.file_manager.cache_file_id_from_data(new_image_data, name) return ActionResponse(status="ok", retcode=0, data={"file_id": file_id}) @standard_action diff --git a/wechatbot_client/config.py b/wechatbot_client/config.py index ffef664..92508b2 100644 --- a/wechatbot_client/config.py +++ b/wechatbot_client/config.py @@ -202,6 +202,7 @@ class Config(BaseConfig): """日志保存天数""" cache_days: int = 3 """文件缓存天数""" - + push_plus_token :str= "" + """push_plus的token""" class Config: extra = "allow" diff --git "a/\345\244\207\345\277\230\345\275\225.py" "b/\345\244\207\345\277\230\345\275\225.txt" similarity index 65% rename from "\345\244\207\345\277\230\345\275\225.py" rename to "\345\244\207\345\277\230\345\275\225.txt" index 20adb1b..f293758 100644 --- "a/\345\244\207\345\277\230\345\275\225.py" +++ "b/\345\244\207\345\277\230\345\275\225.txt" @@ -1,4 +1,7 @@ git tag -a v0.0.6 -m "新增删除文件逻辑" -git push origin v0.0.6 \ No newline at end of file +git push origin v0.0.6 + + +