Skip to content
This repository has been archived by the owner on Feb 28, 2023. It is now read-only.

能否增加企业微信通知或者提供一个自定义的WebHook #32

Closed
1gcat opened this issue May 23, 2022 · 4 comments
Closed

能否增加企业微信通知或者提供一个自定义的WebHook #32

1gcat opened this issue May 23, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@1gcat
Copy link

1gcat commented May 23, 2022

由于朋友的安利,打算从Waline转Artalk来啦~
大概看了一下文档,好像没有支持企业微信的通知,不知后面是否有支持的计划?

@leirock
Copy link

leirock commented May 23, 2022

企业微信的接口文档在这里 https://developer.work.weixin.qq.com/document/path/90372

(不用谢😂

@qwqcode qwqcode transferred this issue from ArtalkJS/Artalk May 23, 2022
@qwqcode
Copy link
Member

qwqcode commented May 23, 2022

开启 WebHook 后,创建新评论将以 POST 方式携带 application/json 类型的 Body 数据请求设定 WebHook 地址。

ArtalkGo 配置文件 artalk-go.yml

admin_notify:
    webhook:
      enabled: true
      url: "http://localhost:23387/"

WebHook 请求数据样本

{
  "notify_subject": "",
  "notify_body": "@测试用户:\n\n测试内容\n\nhttps://127.0.0.1/index.html?atk_comment=1057",
  "comment": {
    "id": 1057,
    "content": "测试内容",
    "user_id": 226,
    "nick": "测试用户",
    "email_encrypted": "654236c1e78i4c09a17c4869c9d43910",
    "link": "https://qwqaq.com",
    "ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 12_4_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36",
    "date": "2022-05-23 17:00:23",
    "is_collapsed": false,
    "is_pending": false,
    "is_pinned": false,
    "is_allow_reply": false,
    "rid": 0,
    "badge_name": "",
    "badge_color": "",
    "visible": true,
    "vote_up": 0,
    "vote_down": 0,
    "page_key": "/index.html",
    "page_url": "https://127.0.0.1/index.html",
    "site_name": "ArtalkDocs"
  },
  "parent_comment": null
}

服务器端处理 WebHook 请求示例 webhook_server.js

const http = require("http");

const requestListener = function (req, res) {
  // receive json request
  let body = "";
  req.on("data", function (data) {
    body += data;
  });
  req.on("end", function () {
    let json = "";
    try {
      json = JSON.parse(body);
    } catch {}

    // do something with json
    console.log(json);
    res.end();
  });

  res.writeHead(200);
  res.end("Hello, World!");
};

const server = http.createServer(requestListener);
server.listen(23387);
$ node webhook_server.js

@qwqcode
Copy link
Member

qwqcode commented May 23, 2022

v2.1.8 新增通知 WebHook 支持,微信接入比较麻烦... 🤣 先搁置

@qwqcode qwqcode closed this as completed May 23, 2022
@inkss
Copy link

inkss commented May 23, 2022

微信那个能用的只是文本信息那个 API,其他的花里胡哨的模板只能通过微信企业版查阅。

{
    "agentid": xxxx,
    "msgtype": "text",
    "text": {
        "content": notify_body
    },
    "touser": "@all",
    "enable_duplicate_check": 1,
    "duplicate_check_interval": 60
}

@qwqcode qwqcode added the enhancement New feature or request label Jun 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants