Skip to content

Commit

Permalink
🐛
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles-Hello committed Aug 31, 2023
1 parent 7c83e27 commit dc25163
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ webhook_timeout = 5000
# - Unable 不开启websocket连接
# - Forward 正向websocket连接
# - Backward 反向websocket连接
websocekt_type = "Unable"
websocekt_type = "Backward"
# 反向 WebSocket 连接地址,使用反向websocket时生效
websocket_url = ["ws://127.0.0.1:8080/onebot/v12/ws/"]
# 反向 WebSocket 重连间隔,单位:毫秒,必须大于 0
Expand Down
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Python: 当前文件",
"type": "python",
"request": "launch",
"program": "${file}",
"program": "${workspaceFolder}/main.py", // 设置为 main.py 的路径
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"justMyCode": false
Expand Down
11 changes: 10 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,14 @@
"[python]": {
"editor.defaultFormatter": "ms-python.autopep8"
},
"python.formatting.provider": "none"
"python.formatting.provider": "none",
"sqltools.connections": [
{
"previewLimit": 50,
"driver": "SQLite",
"database": "${workspaceFolder:ComWeChatBotClient2}/data/data.db",
"name": "name"
}
],
"sqltools.useNodeRuntime": true
}
32 changes: 32 additions & 0 deletions folder-alias.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"wechatbot_client/action_manager/manager.py": {
"description": "这里发送请求调用com_wechat里面真正实现hook请求"
},
"wechatbot_client/com_wechat/com_wechat.py": {
"description": "这里是接收信息和实现对微信各种接口,方便调用"
},
"wechatbot_client/com_wechat/message.py": {
"description": "拿到信息实现onebotv12的协议-----------各种函数调用"
},
"wechatbot_client/consts.py": {
"description": "定义的全局变量"
},
"wechatbot_client/config.py": {
"description": "配置env文件"
},
"wechatbot_client/startup.py": {
"description": "所有任务的启动器"
},
"wechatbot_client/wechat/adapter.py": {
"description": "拿到已经处理后的onebotv12的信息发送给 websocket连接处理"
},
"wechatbot_client/wechat/wechat.py": {
"description": "这里调用com_wechat的message处理形成onebov12信息后然后发送给ws端"
},
"wechatbot_client/driver/driver.py": {
"description": "这里用来连接ws服务"
},
"wechatbot_client/driver": {
"description": "这个driver不用研究"
}
}
11 changes: 0 additions & 11 deletions id.xml

This file was deleted.

Empty file added name.session.sql
Empty file.
5 changes: 5 additions & 0 deletions tempCodeRunnerFile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@



if __name__ == "__main__":
wechatbot_client.run()
1 change: 1 addition & 0 deletions wechatbot_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def init() -> None:
logger.debug(f"Loaded <y><b>Config</b></y>: {str(config.dict())}")

_WeChat = WeChatManager(config)
#这里初始化配置文件
_WeChat.init()


Expand Down
11 changes: 10 additions & 1 deletion wechatbot_client/file_manager/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from uuid import uuid4

from httpx import URL, AsyncClient
import os

from wechatbot_client.consts import DOWNLOAD_TIMEOUT, FILE_CACHE
from wechatbot_client.utils import logger_wrapper, run_sync
Expand Down Expand Up @@ -154,7 +155,15 @@ def clean_tempfile(self, file_paths: list[str]) -> int:
file.unlink()
count += 1
return count

async def clear_directory(self,directory_path):
try:
for root, dirs, files in os.walk(directory_path):
for file in files:
file_path = os.path.join(root, file)
os.remove(file_path)
print(f"Contents of directory '{directory_path}' have been cleared.")
except Exception as e:
print(f"Error clearing directory contents '{directory_path}': {e}")
async def clean_cache(self, days: int = 3) -> int:
"""
说明:
Expand Down
3 changes: 3 additions & 0 deletions wechatbot_client/startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,6 @@ async def clean_filecache(days: int) -> None:
logger.info("<g>开始清理文件缓存任务...</g>")
nums = await wechat.file_manager.clean_cache(days)
logger.success(f"<g>清理缓存完成,共清理 {nums} 个文件...</g>")
directory_to_clear = "file_cache"
await wechat.file_manager.clear_directory(directory_to_clear)

2 changes: 2 additions & 0 deletions wechatbot_client/wechat/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ async def _backward_ws(self, url: URL) -> None:
log("ERROR", f"发送connect事件失败:{e}")
# 发送update事件
event = self.get_status_update_event()
g = event.json(ensure_ascii=False, cls=DataclassEncoder)
print(g)
try:
await websocket.send(
event.json(ensure_ascii=False, cls=DataclassEncoder)
Expand Down
4 changes: 2 additions & 2 deletions 备忘录.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@


git tag -a v0.0.4 -m "debug"
git push origin v0.0.4
git tag -a v0.0.6 -m "新增删除文件逻辑"
git push origin v0.0.6

0 comments on commit dc25163

Please sign in to comment.