Coder Social home page Coder Social logo

tlikai / hwamei Goto Github PK

View Code? Open in Web Editor NEW
200.0 15.0 25.0 97 KB

企业微信webhook,企业微信群机器人webhook,支持Github、Gitlab、Sentry等Webhook

Home Page: https://dinglingdingling.com?utm_source=github_website

Shell 1.15% Batchfile 1.15% JavaScript 97.70%
wxwork webhook sentry gitlab github jenkins

hwamei's Introduction

hwamei

推荐使用 DinglingDingling 替代本项目,无需部署,简单配置即可打通企业微信群机器人与Github、Gitlab、Sentry、Jenkins 等工具 webhook。

hwamei 是一个基于 hubot 的企业微信聊天机器人,它能够通过 webhook 将收集的信息发送到企业微信群中。

已兼容企业微信原生webhook机器人!!! 具体见 #2

预览

企业微信群聊天机器人

工作流程

工作流程

安装

  • git clone https://github.com/tlikai/hwamei.git
  • 运行 npm install
  • 复制 sample.env 为 .env
  • 到企业微信后台创建一个应用
  • 将企业微信的 corpId 和 新建应用的 secret 填入 .env 文件

使用

  • 运行 ./bin/hubot 即可启动 hwamei

  • 目前支持通过命令管理企业微信群、管理 webhook

部署

https://github.com/hubotio/hubot/blob/master/docs/deploying.md

企业微信相关命令

  • hwamei>wxwork create chat {chatid} with {users} 创建一个群, users 以英文逗号分隔
  • hwamei>wxwork destroy chat {chatid} 删除一个群
  • hwamei>wxwork show {chatid} 显示群信息
  • hwamei>wxwork add {userid} to {chatid} 添加用户到指定群
  • hwamei>wxwork remove {userid} from {chatid} 从指定群中删除用户

企业微信消息推送文档 https://work.weixin.qq.com/api/doc#90000/90135/90243

webhook 相关命令

  • hwamei>webhook create {name} from {type} to {chatid} 创建一个 webhook
  • hwamei>webhook list 列出所有 webhook
  • hwamei>webhook delete all 删除所有 webhook
  • hwamei>webhook delete {token} 删除一个 webhook
  • hwamei>webhook update {token} {name|type|chat_id} to {value} 修改一个 webhook
  • hwamei>webhook backup 备份 webhooks 到 ./data/webhooks.json
  • hwamei>webhook restore 恢复 webhooks

webhook 使用

  1. 先创建 webhook
  • hwamei>webhook create test_incoming_webhook from incoming to test
  • 上面命令会创建一个名为 test_incoming_webhook 的 webhook,接收 incoming 类型的输入,输出到 test 企业微信群
  • 运行命令后系统会输出 webhook url,像这个 url 发送请求即可触发 webhook
  • There is your webhook url: /incoming/408dcc98-60a6-4a10-8c77-4679dd9a0a40
  1. 测试 webhook
  • shell>curl -XPOST http://localhost:8080/incoming/408dcc98-60a6-4a10-8c77-4679dd9a0a40 -H 'Content-type: application/json' -d '{ "message": "hello hwamei" }'
  • 运行上面的命令,正常情况下你的企业微信群应该就收到消息了
  1. 目前支持下列几种类型的 webhook type
  • incoming
    • { "message": "hello hwamei" }
    • { "text": "hello hwamei" }
  • sentry
  • gitlab
  • github

扩展更多命令

查看 https://github.com/hubotio/hubot/blob/master/docs/scripting.md

hwamei's People

Contributors

madao-3 avatar ser163 avatar tlikai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hwamei's Issues

generateUUID函数找不到.

hwamei> [Sat Jun 01 2019 01:53:57 GMT+0800 (China Standard Time)] ERROR ReferenceError: generateUUID is not defined
at TextListener.robot.hear [as callback] (/opt/hwamei/scripts/webhook.js:26:19)
at executeListener (/opt/hwamei/node_modules/hubot/src/listener.coffee:65:11, :53:19)
at allDone (/opt/hwamei/node_modules/hubot/src/middleware.coffee:44:37, :34:16)
at /opt/hwamei/node_modules/async/lib/async.js:274:13
at Object.async.eachSeries (/opt/hwamei/node_modules/async/lib/async.js:142:20)
at Object.async.reduce (/opt/hwamei/node_modules/async/lib/async.js:268:15)
at /opt/hwamei/node_modules/hubot/src/middleware.coffee:49:7, :37:22
at process._tickCallback (internal/process/next_tick.js:61:11)
应该是作者更新版本的过程中误删除了.

请教开发组我在安装时报错

开发组成员
您好
我按照咱们的文档进行安装和部署时
在运行 ./bin/hubot 后报错
以下是从linux终端复制过来的报错内容,请您帮我看看哪里有问题谢谢。

./bin/hubot                             
hwamei> [Wed Oct 24 2018 14:03:56 GMT+0800 (CST)] ERROR Unable to load /home/itom/hwamei/scripts/webhook: /home/itom/hwamei/scripts/webhook.js:124
    async function sendMessage(chatId, messageObject){
          ^^^^^^^^

SyntaxError: Unexpected token function
  at createScript (vm.js:56:10)
  at Object.runInThisContext (vm.js:97:10)
  at Module._compile (module.js:549:28)
  at Object.Module._extensions..js (module.js:586:10)
  at Module.load (/home/itom/hwamei/node_modules/coffee-script/lib/coffee-script/coffee-script.js:211:36)
  at tryModuleLoad (module.js:453:12)
  at Function.Module._load (module.js:445:3)
  at Module.require (module.js:504:17)
  at require (internal/module.js:20:19)
  at Robot.loadFile (/home/itom/hwamei/node_modules/hubot/src/robot.coffee:355:9, <js>:224:20)
  at Robot.load (/home/itom/hwamei/node_modules/hubot/src/robot.coffee:377:9, <js>:247:30)
  at Shell.loadScripts (/home/itom/hwamei/node_modules/hubot/bin/hubot:93:5, <js>:97:13)
  at Shell.g (events.js:292:16)
  at emitNone (events.js:86:13)
  at Shell.emit (events.js:185:7)
  at /home/itom/hwamei/node_modules/hubot/src/adapters/shell.coffee:35:7, <js>:72:22
  at /home/itom/hwamei/node_modules/hubot/src/adapters/shell.coffee:101:9, <js>:163:18
  at FSReqWrap.cb [as oncomplete] (fs.js:259:19)

群机器人和github 联通出现问题

感谢作者(见 https://github.com/tlikai/hwamei/pull/2#issuecomment-602191979)!

我尝试和Github webhook 联通,但是一直出现 service timeout。

本地推送正常

如果是在服务器上部署完成后,本地通过下面方式运行,群机器人可以正常推送消息。 (隐藏了ip地址和群机器人的id)

curl -XPOST http://serverip:8080/wxwork_webhook/incoming/botid -H 'Content-type: application/json' -d '{ "message": "hello world" }'

链接Github 异常

但是连到github以后,出现service timeout:

进一步测试发现,github 推送虽然为 service timeout,但是企业微信不定期收到undefined 的消息, 考虑过是否和翻墙有关,服务器用国内aws和海外DigitalOcean 都会出现timeout

企业微信端截图:

image

海外服务器截图:

image

【功能建议】企业微信消息能否添加项目名称

目前使用 Dingling 创建 Gitlab 消息后, 在企业收到的消息体结构 以 提交 为例 类似:


Author 推送了 n 个新的提交到 branch 分支

hash - commit message

建议修改成

Author 推送了 n 个新的提交到 project 的 branch 分支

hash - commit message

增加 项目名称,使用起来更方便

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.