go-wxhelper/tcpserver/forward.go
李寻欢 63d50b815c
All checks were successful
BuildImage / build-image (push) Successful in 1m30s
🆕 支持转发消息到外部服务(暂时只支持socket)
2023-12-06 10:16:52 +08:00

26 lines
471 B
Go

package tcpserver
import (
"go-wechat/config"
"log"
"net"
)
// forward
// @description: 转发消息
func forward(msg []byte) {
// 使用socket转发消息
for _, s := range config.Conf.Wechat.Forward {
conn, err := net.Dial("tcp", s)
if err != nil {
log.Printf("转发消息失败,错误信息: %v", err)
continue
}
_, err = conn.Write(msg)
if err != nil {
log.Printf("转发消息失败,错误信息: %v", err)
}
_ = conn.Close()
}
}