JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
fix(cron): 修复微信频道无法执行定时任务的问题
xiaoyao42f52f524c2ea5
diff --git "a/docs/zh/\351\242\221\351\201\223.md" "b/docs/zh/\351\242\221\351\201\223.md"index 857c8c2ec0..5186d5fb7f 100644--- "a/docs/zh/\351\242\221\351\201\223.md"+++ "b/docs/zh/\351\242\221\351\201\223.md"@@ -486,6 +486,9 @@ channels:- 你是**安卓**或**IOS**用户- 你是**鸿蒙**用户,且不介意使用**卓易通**++> 💡 **提示**:当用户向 ClawBot 发送一条消息后,应用最多可以向该用户发送 **10 条**独立消息(包括回复的消息)。若用户再次像ClawBot发送消息,配额将重置为 10。+## 2. 安卓或IOS接入### 步骤 1:微信版本升级diff --git a/jiuwenclaw/channel/wechat_channel.py b/jiuwenclaw/channel/wechat_channel.pyindex eb53bab483..675d1ed1f4 100644--- a/jiuwenclaw/channel/wechat_channel.py+++ b/jiuwenclaw/channel/wechat_channel.py@@ -894,6 +894,16 @@ class WechatChannel(BaseChannel):if context_token:self._context_tokens[user_id] = context_token+ # 持久化 last_user_id 和 context_token 供 cron/心跳推送使用+ try:+ from jiuwenclaw.config import update_channel_in_config+ updates: dict[str, str] = {"last_user_id": user_id}+ if context_token:+ updates["last_context_token"] = context_token+ update_channel_in_config("wechat", updates)+ except Exception as exc:+ logger.warning("persist channel config failed: %s", exc)+text, ref_text = self._parse_item_list(wx_msg.get("item_list") or [])if not text and not ref_text:returndiff --git a/jiuwenclaw/gateway/cron/models.py b/jiuwenclaw/gateway/cron/models.pyindex ea27d3620a..0ef18befa1 100644--- a/jiuwenclaw/gateway/cron/models.py+++ b/jiuwenclaw/gateway/cron/models.py@@ -13,6 +13,7 @@ class CronTargetChannel(str, Enum):WHATSAPP = "whatsapp"WECOM = "wecom"XIAOYI = "xiaoyi"+ WECHAT = "wechat"# DINGTALK = "dingtalk"diff --git a/jiuwenclaw/gateway/cron/scheduler.py b/jiuwenclaw/gateway/cron/scheduler.pyindex 5741ae9780..cf4a301434 100644--- a/jiuwenclaw/gateway/cron/scheduler.py+++ b/jiuwenclaw/gateway/cron/scheduler.py@@ -499,6 +499,17 @@ class CronSchedulerService:metadata = {"wecom_chat_id": last_chat_id,}+ elif channel_id == "wechat":+ last_user_id = str(ch_cfg.get("last_user_id") or "").strip()+ last_context_token = str(ch_cfg.get("last_context_token") or "").strip()+ if last_user_id:+ metadata = {+ "wechat_user_id": last_user_id,+ "reply_to_user_id": last_user_id,+ }+ if last_context_token:+ metadata["wechat_context_token"] = last_context_token+ metadata["context_token"] = last_context_tokenexcept Exception:metadata = Nonediff --git a/jiuwenclaw/web/src/components/CronPanel/index.tsx b/jiuwenclaw/web/src/components/CronPanel/index.tsxindex 666a215bf0..53a154e402 100644--- a/jiuwenclaw/web/src/components/CronPanel/index.tsx+++ b/jiuwenclaw/web/src/components/CronPanel/index.tsx@@ -188,6 +188,7 @@ export default function CronPanel({ sessionId }: CronPanelProps) {{ value: 'web', label: t('cron.targets.web') },{ value: 'feishu', label: t('cron.targets.feishu') },{ value: 'wecom', label: t('cron.targets.wecom') },+ { value: 'wechat', label: t('cron.targets.wechat') },{ value: 'xiaoyi', label: t('cron.targets.xiaoyi'), disabled: true, style: { color: '#8c8c96ff' } },{ value: 'dingtalk', label: t('cron.targets.dingtalk'), disabled: true, style: { color: '#8c8c96ff' } },];diff --git a/jiuwenclaw/web/src/i18n/locales/en.json b/jiuwenclaw/web/src/i18n/locales/en.jsonindex 438855531c..89f892a300 100644--- a/jiuwenclaw/web/src/i18n/locales/en.json+++ b/jiuwenclaw/web/src/i18n/locales/en.json@@ -162,6 +162,7 @@"channels": {"web": "Web (web)","feishu": "Lark (feishu)",+ "wechat": "WeChat (wechat)","wecom": "WeCom (wecom)","xiaoyi": "Xiaoyi (xiaoyi)","dingtalk": "DingTalk (dingtalk)"@@ -441,6 +442,7 @@"targets": {"web": "Web (web)","feishu": "Lark (feishu)",+ "wechat": "WeChat (wechat)","wecom": "WeCom (wecom)","xiaoyi": "Xiaoyi (xiaoyi)","dingtalk": "DingTalk (dingtalk)"diff --git a/jiuwenclaw/web/src/i18n/locales/zh.json b/jiuwenclaw/web/src/i18n/locales/zh.jsonindex 8cc669f9e1..e6e619e687 100644--- a/jiuwenclaw/web/src/i18n/locales/zh.json+++ b/jiuwenclaw/web/src/i18n/locales/zh.json@@ -162,6 +162,7 @@"channels": {"web": "网页 (web)","feishu": "飞书 (feishu)",+ "wechat": "微信 (wechat)","wecom": "企业微信 (wecom)","xiaoyi": "小艺 (xiaoyi)","dingtalk": "钉钉 (dingtalk)"@@ -441,6 +442,7 @@"targets": {"web": "网页 (web)","feishu": "飞书 (feishu)",+ "wechat": "微信 (wechat)","wecom": "企业微信 (wecom)","xiaoyi": "小艺 (xiaoyi)","dingtalk": "钉钉 (dingtalk)"