|
@@ -2,7 +2,6 @@ package nodes
|
|
|
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
- "fmt"
|
|
|
"github.com/gogf/gf/encoding/gjson"
|
|
|
"github.com/gogf/gf/os/grpool"
|
|
|
"net/http"
|
|
@@ -25,7 +24,6 @@ type DingTalkRobotNodeConfig struct {
|
|
|
}
|
|
|
|
|
|
func (d *DingTalkRobotNode) Init(ctx ruleEngine.Context, config string) error {
|
|
|
- fmt.Printf("初始化钉钉机器人节点---------------\n")
|
|
|
d.pool = grpool.New(10)
|
|
|
if config == "" {
|
|
|
d.config = &DingTalkRobotNodeConfig{
|
|
@@ -46,14 +44,12 @@ func (d *DingTalkRobotNode) Init(ctx ruleEngine.Context, config string) error {
|
|
|
}
|
|
|
|
|
|
func (d *DingTalkRobotNode) OnMessage(ctx ruleEngine.Context, message *protocol.Message) error {
|
|
|
- fmt.Printf("执行钉钉机器人节点--------------\n")
|
|
|
body, err := d.newBody(message)
|
|
|
if body == nil {
|
|
|
return nil
|
|
|
} else if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
- fmt.Printf("webhook:-----------%s\n", d.config.WebHook)
|
|
|
req, err := d.client.Post(d.config.WebHook, "application/json", gjson.New(body))
|
|
|
|
|
|
return d.pool.Add(func() {
|
|
@@ -78,6 +74,5 @@ func (d *DingTalkRobotNode) newBody(message *protocol.Message) (body map[string]
|
|
|
"msgtype": "text",
|
|
|
"text": msg,
|
|
|
}
|
|
|
- fmt.Printf("message222222:-----------%s\n", body)
|
|
|
return body, nil
|
|
|
}
|