Coder Social home page Coder Social logo

trumpet's Introduction

🎺trumpet GitHub release (latest by date) Docker Pulls GolangCI GitHub Workflow Status GitHub license

Webhook message transform service


English | 简体中文

Usage

Quick start

docker run -d -p 8080:8080 elonzh/trumpet
feishu_webhook='<your-feishu-webhook-url>'
curl "http://127.0.0.1:8080/transformers/dingtalk-to-feishu?trumpet_to=${feishu_webhook}" \
    -v -X "POST" -H "Content-Type: application/json" \
    -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:

def transform(request):
    # print(requst["headers"])
    # print(requst["body"])
    msg_type = request["body"]["msg_type"]
    body = {}
    if msg_type == "text":
        body = {
            "msgtype": "text",
            "text": {"content": request["body"]["content"]["text"]},
        }
    request["body"] = body
    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!

trumpet's People

Contributors

elonzh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.