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

feat(notify): support wecom group bot notification #2904

Closed
wants to merge 1 commit into from

Conversation

mapxn
Copy link
Contributor

@mapxn mapxn commented Jan 15, 2025

支持新的通知方式:企业微信群机器人

Refs: #2655#2753#2661

感谢 @lizheming 的指导,现已加入对企业微信群机器人的支持。

参考:企业微信群机器人 开发文档

已通过本地测试,并更新了官方文档。

@mapxn
Copy link
Contributor Author

mapxn commented Jan 16, 2025

本次改动如下:

  1. 添加了新的环境变量:WECOM_GROUP_WEBHOOK,用于自定义企业微信群机器人webhook链接(注:Wecom为企业微信的官方英文名称)。
  2. 添加了新的调用函数wecomgroup,用于发送通知。
  3. 添加对应的文档说明。

具体改动见 Files Changed

测试日志如下:

/workspace/waline (main) $ node ./packages/server/vanilla.js
[2025-01-16T02:02:30.107] [1250] [INFO] - Server running at http://127.0.0.1:8360
[2025-01-16T02:02:30.108] [1250] [INFO] - ThinkJS version: 3.2.15
[2025-01-16T02:02:30.109] [1250] [INFO] - Environment: production
[2025-01-16T02:02:30.109] [1250] [INFO] - Workers: 1
(node:1261) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
[2025-01-16T02:02:50.355] [1261] [DEBUG] - Post Comment Start!
[2025-01-16T02:02:50.355] [1261] [DEBUG] - Post Comment initial Data: {
  link: 'test.com',
  mail: '[email protected]',
  nick: '张三',
  pid: undefined,
  rid: undefined,
  ua: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
  url: '/',
  comment: '评论测试',
  ip: '114.94.77.73',
  insertedAt: '2025-01-16T02:02:50.355Z',
  user_id: undefined
}
[2025-01-16T02:02:50.356] [1261] [DEBUG] - Comment IP 114.94.197.23 check OK!
[2025-01-16T02:02:50.441] [1261] [DEBUG] - Comment duplicate check OK!
[2025-01-16T02:02:50.807] [1261] [DEBUG] - Comment post frequency check OK!
[2025-01-16T02:02:50.807] [1261] [DEBUG] - Comment initial status is approved
[2025-01-16T02:02:51.183] [1261] [DEBUG] - Comment akismet check result: approved
[2025-01-16T02:02:51.184] [1261] [DEBUG] - Comment keyword check result: approved
[2025-01-16T02:02:51.184] [1261] [DEBUG] - Comment post hooks preSave done!
[2025-01-16T02:02:51.646] [1261] [DEBUG] - Comment have been added to storage.
Wecom Group Notification Success: {"errcode":0,"errmsg":"ok"}
Notification mail send success: undefined
[2025-01-16T02:02:52.525] [1261] [DEBUG] - Comment notify done!
[2025-01-16T02:02:52.525] [1261] [DEBUG] - Comment post hooks postSave done!

PC端评论截图:
image

手机端消息截图:
image

@Mister-Hope @lizheming 如果有时间请帮忙review下代码,看是否满足合并要求

@lizheming
Copy link
Collaborator

lizheming commented Jan 16, 2025

这个企业微信 QQ 群通知的能力,能否做成插件的形式呢,后期相关的通知能力也会转成插件的形式支持


Can this enterprise WeChat QQ group notification capability be made into a plug-in form? Later related notification capabilities will also be converted into a plug-in form to support

@mapxn
Copy link
Contributor Author

mapxn commented Jan 16, 2025

这个企业微信 QQ 群通知的能力,能否做成插件的形式呢,后期相关的通知能力也会转成插件的形式支持

Can this enterprise WeChat QQ group notification capability be made into a plug-in form? Later related notification capabilities will also be converted into a plug-in form to support

👍 这是个好主意,一些附加功能通过插件形式提供,核心功能尽量紧凑精简。但可能要花时间研究下插件了

@mapxn
Copy link
Contributor Author

mapxn commented Jan 16, 2025

https://waline.js.org/reference/server/plugin.html#%E5%AE%89%E8%A3%85%E6%8F%92%E4%BB%B6 https://waline.js.org/reference/server/config.html#postsave-comment-pcomment

可以看看文档,挺简单的

确实挺简单的,一个中午就写完代码且测试好了(企微群机器人评论插件),稍后提交一个PR到plugins仓库。

@mapxn mapxn closed this Jan 16, 2025
@mapxn
Copy link
Contributor Author

mapxn commented Jan 16, 2025

后期相关的通知能力也会转成插件的形式支持

@lizheming 对于后期通知方式的支持,是希望做成每种通知方式都独立的一个插件,还是统一集成在一个统一的Notification插件内?


Later related notification capabilities will also be converted into plug-in support

@lizheming Regarding the support for later notification methods, do you want to make each notification method an independent plug-in, or do you want it to be integrated into a unified Notification plug-in?

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

Successfully merging this pull request may close these issues.

2 participants