mirror of
https://github.com/lddsb/drone-dingtalk-message.git
synced 2026-06-16 14:50:42 +08:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b7390525e1 | |||
| 9df9c9aa37 |
@@ -36,6 +36,10 @@ String. Access token for group bot. (you can get the access token when you add a
|
||||
|
||||
String. Message type, plan support text, markdown, link and action card, but due to time issue, it's only support `markdown` and `text` now, and you can get the best experience by use markdown.
|
||||
|
||||
`tips_title`
|
||||
|
||||
String. You can customize the title for the message tips, just work when message type is markdown.
|
||||
|
||||
`message_color`(when `type=markdown`)
|
||||
|
||||
Boolean value. This option can change the title and commit message color if turn on.
|
||||
@@ -113,4 +117,4 @@ cd $GOPATH/src/github.com/lddsb/drone-dingtalk-message && go build .
|
||||
- run
|
||||
```shell
|
||||
./drone-dingtalk-message -h
|
||||
```
|
||||
```
|
||||
|
||||
@@ -144,6 +144,11 @@ func main() {
|
||||
Usage: "link sha source page or not",
|
||||
EnvVar: "PLUGIN_SHA_LINK,PLUGIN_MESSAGE_SHA_LINK",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "config.tips.title",
|
||||
Usage: "tips title, just work for markdown type message",
|
||||
EnvVar: "PLUGIN_TIPS_TITLE",
|
||||
},
|
||||
}
|
||||
|
||||
if err := app.Run(os.Args); nil != err {
|
||||
@@ -184,10 +189,11 @@ func run(c *cli.Context) {
|
||||
Config: Config{
|
||||
AccessToken: c.String("config.token"),
|
||||
//Lang: c.String("config.lang"),
|
||||
IsAtALL: c.Bool("config.message.at.all"),
|
||||
MsgType: c.String("config.message.type"),
|
||||
Mobiles: c.String("config.message.at.mobiles"),
|
||||
Debug: c.Bool("config.debug"),
|
||||
IsAtALL: c.Bool("config.message.at.all"),
|
||||
MsgType: c.String("config.message.type"),
|
||||
Mobiles: c.String("config.message.at.mobiles"),
|
||||
Debug: c.Bool("config.debug"),
|
||||
TipsTitle: c.String("config.tips.title"),
|
||||
},
|
||||
Extra: Extra{
|
||||
Pic: ExtraPic{
|
||||
|
||||
@@ -52,6 +52,7 @@ type (
|
||||
Mobiles string
|
||||
Username string
|
||||
MsgType string
|
||||
TipsTitle string
|
||||
}
|
||||
|
||||
// MessageConfig `DingTalk message struct`
|
||||
@@ -108,11 +109,15 @@ func (p *Plugin) Exec() error {
|
||||
return errors.New("commit sha cannot short than 6")
|
||||
}
|
||||
|
||||
if p.Config.TipsTitle == "" {
|
||||
p.Config.TipsTitle = "you have a new message"
|
||||
}
|
||||
|
||||
newWebhook := webhook.NewWebHook(p.Config.AccessToken)
|
||||
mobiles := strings.Split(p.Config.Mobiles, ",")
|
||||
switch strings.ToLower(p.Config.MsgType) {
|
||||
case "markdown":
|
||||
err = newWebhook.SendMarkdownMsg("You have a new message...", p.baseTpl(), p.Config.IsAtALL, mobiles...)
|
||||
err = newWebhook.SendMarkdownMsg(p.Config.TipsTitle, p.baseTpl(), p.Config.IsAtALL, mobiles...)
|
||||
case "text":
|
||||
err = newWebhook.SendTextMsg(p.baseTpl(), p.Config.IsAtALL, mobiles...)
|
||||
case "link":
|
||||
@@ -232,12 +237,12 @@ get picture url
|
||||
func (p *Plugin) getPicURL() string {
|
||||
pics := make(map[string]string)
|
||||
// success picture url
|
||||
pics["success"] = "https://ws4.sinaimg.cn/large/006tNc79gy1fz05g5a7utj30he0bfjry.jpg"
|
||||
pics["success"] = "https://wx1.sinaimg.cn/large/006tNc79gy1fz05g5a7utj30he0bfjry.jpg"
|
||||
if p.Extra.Pic.SuccessPicURL != "" {
|
||||
pics["success"] = p.Extra.Pic.SuccessPicURL
|
||||
}
|
||||
// failure picture url
|
||||
pics["failure"] = "https://ws1.sinaimg.cn/large/006tNc79gy1fz0b4fghpnj30hd0bdmxn.jpg"
|
||||
pics["failure"] = "https://wx1.sinaimg.cn/large/006tNc79gy1fz0b4fghpnj30hd0bdmxn.jpg"
|
||||
if p.Extra.Pic.FailurePicURL != "" {
|
||||
pics["failure"] = p.Extra.Pic.FailurePicURL
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user