mirror of
https://github.com/miloira/wxhook.git
synced 2024-11-22 02:19:26 +08:00
version 0.0.2
This commit is contained in:
parent
86adcc7152
commit
a9fcc7a0c0
@ -2,7 +2,7 @@
|
||||
|
||||
## 简介
|
||||
|
||||
WxHook是一个基于dll注入实现的python微信机器人框架,支持多种接口、高扩展性、多线程事件高并发,让你轻松应对海量消息,为你的需求实现提供便捷灵活的支持。
|
||||
WxHook是一个基于dll注入实现的python微信机器人框架,支持多种接口、高扩展性、多线程消息处理,让你轻松应对海量消息,为你的需求实现提供便捷灵活的支持。
|
||||
|
||||
支持的接口
|
||||
1. hook同步消息
|
||||
|
2
setup.py
2
setup.py
@ -18,7 +18,7 @@ URL = 'https://github.com/miloira/wxhook'
|
||||
EMAIL = '690126048@qq.com'
|
||||
AUTHOR = 'Msky'
|
||||
REQUIRES_PYTHON = '>=3.8.0'
|
||||
VERSION = '0.0.1'
|
||||
VERSION = '0.0.2'
|
||||
|
||||
# What packages are required for this module to be executed?
|
||||
REQUIRED = [
|
||||
|
@ -1,3 +1,3 @@
|
||||
from .core import Bot
|
||||
|
||||
version = "0.0.1"
|
||||
version = "0.0.2"
|
||||
|
@ -1,12 +1,12 @@
|
||||
import os
|
||||
import json
|
||||
import typing
|
||||
import traceback
|
||||
import socketserver
|
||||
from functools import lru_cache
|
||||
|
||||
import psutil
|
||||
import pyee
|
||||
import traceback
|
||||
import socketserver
|
||||
|
||||
import requests
|
||||
|
||||
from .events import ALL_MESSAGE, SYSTEM_MESSAGE
|
||||
@ -62,8 +62,8 @@ class Bot:
|
||||
self.remote_port, self.server_port = self.wechat_manager.get_port()
|
||||
self.BASE_URL = f"http://{self.remote_host}:{self.remote_port}"
|
||||
self.webhook_url = None
|
||||
self.info = None
|
||||
self.DATA_SAVE_PATH = None
|
||||
self.WXHELPER_PATH = None
|
||||
self.FILE_SAVE_PATH = None
|
||||
self.IMAGE_SAVE_PATH = None
|
||||
self.VIDEO_SAVE_PATH = None
|
||||
@ -93,12 +93,11 @@ class Bot:
|
||||
|
||||
def init_bot(self, bot: "Bot", event: Event) -> None:
|
||||
if event.content["sysmsg"]["@type"] == "SafeModuleCfg":
|
||||
bot.info = bot.get_self_info()
|
||||
self.DATA_SAVE_PATH = bot.info.dataSavePath
|
||||
self.FILE_SAVE_PATH = os.path.join(self.DATA_SAVE_PATH, "wxhelper/file")
|
||||
self.IMAGE_SAVE_PATH = os.path.join(self.DATA_SAVE_PATH, "wxhelper/image")
|
||||
self.VIDEO_SAVE_PATH = os.path.join(self.DATA_SAVE_PATH, "wxhelper/video")
|
||||
logger.info(bot.info)
|
||||
self.WXHELPER_PATH = os.path.join(self.DATA_SAVE_PATH, "wxhelper")
|
||||
self.FILE_SAVE_PATH = os.path.join(self.WXHELPER_PATH, "file")
|
||||
self.IMAGE_SAVE_PATH = os.path.join(self.WXHELPER_PATH, "image")
|
||||
self.VIDEO_SAVE_PATH = os.path.join(self.WXHELPER_PATH, "video")
|
||||
self.call_hook_func(self.on_login, bot)
|
||||
|
||||
def set_webhook_url(self, webhook_url: str) -> None:
|
||||
@ -148,6 +147,7 @@ class Bot:
|
||||
"""检查登录状态"""
|
||||
return Response(**self.call_api("/api/checkLogin"))
|
||||
|
||||
@lru_cache
|
||||
def get_self_info(self) -> Account:
|
||||
"""获取用户信息"""
|
||||
return Account(**self.call_api("/api/userInfo")["data"])
|
||||
@ -234,7 +234,7 @@ class Bot:
|
||||
data = {
|
||||
"wxid": wxid
|
||||
}
|
||||
return ContactDetail(self.call_api("/api/getContactProfile", json=data)["data"])
|
||||
return ContactDetail(**self.call_api("/api/getContactProfile", json=data)["data"])
|
||||
|
||||
def create_room(self, member_ids: list[str]) -> Response:
|
||||
"""创建群聊"""
|
||||
@ -423,6 +423,10 @@ class Bot:
|
||||
"""测试"""
|
||||
return Response(**self.call_api("/api/test"))
|
||||
|
||||
@property
|
||||
def info(self) -> Account:
|
||||
return self.get_self_info()
|
||||
|
||||
def on_event(self, raw_data: bytes):
|
||||
try:
|
||||
data = json.loads(raw_data)
|
||||
|
Loading…
Reference in New Issue
Block a user