Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

只能保持设备一直在线才能获取消息【限制性】 #1

Open
leodknuth opened this issue Dec 21, 2024 · 0 comments
Open

Comments

@leodknuth
Copy link

结论:

如果要完整获得所有微信消息,必须保持24小时程序在后台运行。该方案可用性不强。

分析过程:

疑问:

我的设备无法保持24小时开机,当设备关闭重新启动,服务重新恢复后,没有被同步的信息是否会同步过来?

不会自动同步离线期间的消息。这是因为 WeChat 协议的限制,机器人只能获取在线时收到的消息。
对于这种情况,我建议:

  • 如果需要完整的聊天记录,可以考虑:
  • 使用微信自带的聊天记录导出功能
  • 或者在重要对话时确保机器人在线

技术限制分析:

// 当前项目使用的是 wechaty-puppet-wechat4u

import { WechatyBuilder } from "wechaty";
const bot = WechatyBuilder.build({
  puppet: "wechaty-puppet-wechat4u",
  ...
});

经过查证:

wechaty-puppet-wechat4u 是基于网页版微信的协议
网页版微信的历史消息获取有严格限制
room.messages() API 实际上只能获取内存中的消息,而不是真正的历史消息

替代方案评估:

// 其他可用的 puppet:
// - wechaty-puppet-padlocal (付费)
// - wechaty-puppet-xp (需要 Windows)
// - wechaty-puppet-service (需要token)

实际限制:

  • 大多数微信账号已无法使用网页版
  • 即使可以使用,也只能获取最近的消息
  • 重启后无法获取离线期间的消息
  • 风险评估:
  • 频繁调用历史消息API可能触发封号风险
  • 同步过程可能会消耗大量资源
  • 可能会有大量重复消息需要处理
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant