- 新增微信 Gateway 与 Provider 基类,为多版本 server 切换预留入口 - 将 855/859 现有协议实现迁入 providers/legacy_855 独立目录管理 - 保留 WechatAPIClient 旧命名出口,先维持调用面兼容并带上运行资源文件
51 lines
1.8 KiB
Python
51 lines
1.8 KiB
Python
from wechat_ipad import UserLoggedOut
|
||
from wechat_ipad.provider_base import WechatProviderBase
|
||
from wechat_ipad.providers.legacy_855.friend_circle import FriendCircleMixin
|
||
from wechat_ipad.providers.legacy_855.friends import FriendMixin
|
||
from wechat_ipad.providers.legacy_855.group import ChatroomMixin
|
||
from wechat_ipad.providers.legacy_855.login import LoginMixin
|
||
from wechat_ipad.providers.legacy_855.message import MessageMixin
|
||
from wechat_ipad.providers.legacy_855.tools import ToolMixin
|
||
from wechat_ipad.providers.legacy_855.user import UserMixin
|
||
|
||
|
||
class Legacy855WechatClient(
|
||
LoginMixin,
|
||
MessageMixin,
|
||
FriendCircleMixin,
|
||
FriendMixin,
|
||
ChatroomMixin,
|
||
UserMixin,
|
||
ToolMixin,
|
||
WechatProviderBase,
|
||
):
|
||
"""855/859 风格 server 的独立 Provider。
|
||
|
||
说明:
|
||
1. 这里不再直接依赖旧 `wechat_ipad/client/` 目录,而是将当前现网协议实现收口到独立 provider 目录;
|
||
2. 对外仍继续暴露与旧 `WechatAPIClient` 基本兼容的方法名,减少第一阶段替换成本;
|
||
3. 第二阶段接入 864 时,会新增独立 provider,而不是继续向本类堆条件分支。
|
||
"""
|
||
|
||
provider_name = "legacy_855"
|
||
server_type = "legacy_855"
|
||
|
||
async def send_at_message(self, wxid: str, content: str, at: list[str]) -> tuple[int, int, int]:
|
||
"""发送 @ 消息,兼容现有插件调用方式。"""
|
||
if not self.wxid:
|
||
raise UserLoggedOut("请先登录")
|
||
|
||
output = ""
|
||
if wxid.endswith("@chatroom"):
|
||
for at_id in at:
|
||
nickname = await self.get_chatroom_nickname(at_id, wxid)
|
||
output += f"@{nickname}\u2005"
|
||
|
||
output += "\n"
|
||
output += content
|
||
else:
|
||
output = content
|
||
|
||
return await self.send_text_message(wxid, output, at)
|
||
|