项目作者: elonzh

项目描述 :
a webhook message transform service
高级语言: Go
项目地址: git://github.com/elonzh/trumpet.git
创建时间: 2020-10-28T07:49:35Z
项目社区:https://github.com/elonzh/trumpet

开源协议:MIT License

下载


Docker Pulls " class="reference-link">🎺trumpet GitHub release (latest by date) Docker Pulls GolangCI GitHub Workflow Status GitHub license

Webhook message transform service


English | 简体中文

Usage

Quick start

  1. docker run -d -p 8080:8080 elonzh/trumpet
  2. feishu_webhook='<your-feishu-webhook-url>'
  3. curl "http://127.0.0.1:8080/transformers/dingtalk-to-feishu?trumpet_to=${feishu_webhook}" \
  4. -v -X "POST" -H "Content-Type: application/json" \
  5. -d '{"msgtype": "text", "text": {"content": "message from trumpet!"}}'

You can mount the configuration in the default configuration path /app/config.yaml, or provide the -c/--config parameter to provide the configuration file path.

Builtin transformers

DingTalk Feishu/Lark

Customize transformers

Starlark is a dialect of Python intended for use as a configuration language.

The message transformer are written by Starlark language,
and what you need to do is defining a transform function, modifying the incoming request accordingly,
for example:

  1. def transform(request):
  2. # print(requst["headers"])
  3. # print(requst["body"])
  4. msg_type = request["body"]["msg_type"]
  5. body = {}
  6. if msg_type == "text":
  7. body = {
  8. "msgtype": "text",
  9. "text": {"content": request["body"]["content"]["text"]},
  10. }
  11. request["body"] = body
  12. return request

Deploy to Kubernetes

The configuration file deployed to the Kubernetes cluster is provided in the manifests folder, you can make adjustments according to your needs.

Contribute

If you want to add or update builtin transformers, just make a pull request!