This commit is contained in:
thsrite
2024-03-23 19:31:11 +08:00
parent e43aeabf12
commit ba5a0bd51a
2 changed files with 18 additions and 8 deletions

View File

@@ -2,6 +2,7 @@
### 更新记录
- 1.2 fix规则
- 1.1 自定义发送额外消息
- 1.0 根据正则转发通知到其他WeChat应用
@@ -12,4 +13,13 @@
企业微信应用配置与正则表达式一一对应(一行对应一行)
如果某条消息不想指定userid发送则填写忽略userid正则表达式
如果某条消息不想指定userid发送则填写忽略userid正则表达式.
额外消息配置
`开始下载 > userid > 后台下载任务已提交,请耐心等候入库通知。 > appid`
中间用` > `分割
消息title匹配到`开始下载`的正则
且消息text中的`用户:`匹配到userid
则发送`后台下载任务已提交,请耐心等候入库通知。`额外通知。
发送给appid为`appid`的企业微信应用。(环境变量配置或者本插件配置均可。)

View File

@@ -20,7 +20,7 @@ class WeChatForward(_PluginBase):
# 插件图标
plugin_icon = "Wechat_A.png"
# 插件版本
plugin_version = "1.1"
plugin_version = "1.2"
# 插件作者
plugin_author = "thsrite"
# 作者主页
@@ -177,7 +177,7 @@ class WeChatForward(_PluginBase):
'model': 'extra_confs',
'rows': '2',
'label': '额外配置',
'placeholder': '开始下载 > 后台下载任务已提交,请耐心等候入库通知。> appid > userid'
'placeholder': '开始下载 > userid > 后台下载任务已提交,请耐心等候入库通知。 > appid'
}
}
]
@@ -279,7 +279,7 @@ class WeChatForward(_PluginBase):
else:
self.__send_message(title, text, userid, access_token, appid, index)
# 正在下载 > 后台下载任务已提交,请耐心等候入库通知。> appid > userid
# 开始下载 > userid > 后台下载任务已提交,请耐心等候入库通知。 > appid
if self._extra_confs:
extra_confs = self._extra_confs.split("\n")
for extra_conf in extra_confs:
@@ -287,9 +287,9 @@ class WeChatForward(_PluginBase):
if len(extras) != 4:
continue
extra_pattern = extras[0]
extra_title = extras[1]
extra_appid = extras[2]
extra_userid = extras[3]
extra_userid = extras[1]
extra_title = extras[2]
extra_appid = extras[3]
if re.search(extra_pattern, title):
logger.info(f"{title} 正则匹配到额外消息 {extra_pattern}")
# 判断text的userId
@@ -299,7 +299,7 @@ class WeChatForward(_PluginBase):
continue
# 获取消息text中的用户
user_id = result.group(1)
if user_id and user_id in extra_userid:
if user_id and any(userid == user for user in extra_userid.split(",")):
logger.info(f"消息用户{user_id} 匹配到目标用户 {extra_userid}")
# 发送额外消息
if str(settings.WECHAT_APP_ID) == str(extra_appid):