1 Star 0 Fork 0

浪图怪人/dingtalk

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
text.go 935 Bytes
一键复制 编辑 原始数据 按行查看 历史
langtu 提交于 2024-12-08 22:24 . update
package dingtalk
import (
"log"
"gitee.com/langtu/dingtalk/pkg/dingtalk"
"github.com/spf13/cobra"
)
var textCmd = &cobra.Command{
Use: "text",
Short: "send text message with DingTalk robot",
Long: `send text message with DingTalk robot`,
Args: cobra.MinimumNArgs(0),
Run: runTextCmd,
}
func runTextCmd(_ *cobra.Command, _ []string) {
if len(textVars.content) < 1 {
log.Fatal("content can not be empty")
return
}
client, err := newClient()
if err != nil {
log.Fatal(err.Error())
return
}
msg := dingtalk.NewTextMessage().
SetContent(textVars.content).
SetAt(atMobiles, isAtAll)
req, _, err := client.Send(msg)
if debug {
log.Print(req)
}
if err != nil {
log.Fatal(err.Error())
}
}
// TextVars struct
type TextVars struct {
content string
}
var textVars TextVars
func init() {
rootCmd.AddCommand(textCmd)
textCmd.Flags().StringVarP(&textVars.content, "content", "c", "", "content")
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/langtu/dingtalk.git
git@gitee.com:langtu/dingtalk.git
langtu
dingtalk
dingtalk
bd9fdc3b6064

搜索帮助