mirror of
https://github.com/appleboy/drone-discord.git
synced 2026-06-04 18:33:47 +08:00
update discord default template.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
@@ -47,7 +47,8 @@ type (
|
||||
|
||||
// EmbedFooterObject for Embed Footer Structure.
|
||||
EmbedFooterObject struct {
|
||||
Text string `json:"text"`
|
||||
Text string `json:"text"`
|
||||
IconURL string `json:"icon_url"`
|
||||
}
|
||||
|
||||
// EmbedAuthorObject for Embed Author Structure
|
||||
@@ -145,17 +146,29 @@ func (p *Plugin) Send() error {
|
||||
|
||||
// Message is plugin default message.
|
||||
func (p *Plugin) Message() {
|
||||
description := ""
|
||||
switch p.Build.Event {
|
||||
case "push":
|
||||
description = fmt.Sprintf("%s pushed to %s", p.Build.Author, p.Build.Branch)
|
||||
case "pull_request":
|
||||
description = fmt.Sprintf("%s created pull request %s", p.Build.Author, p.Build.Branch)
|
||||
case "tag":
|
||||
description = fmt.Sprintf("%s pushed tag %s", p.Build.Author, p.Build.Branch)
|
||||
}
|
||||
|
||||
p.Payload.Embeds = []EmbedObject{
|
||||
{
|
||||
Title: p.Build.Message,
|
||||
URL: p.Build.Link,
|
||||
Color: p.Color(),
|
||||
Title: p.Build.Message,
|
||||
Description: description,
|
||||
URL: p.Build.Link,
|
||||
Color: p.Color(),
|
||||
Author: EmbedAuthorObject{
|
||||
Name: p.Build.Author,
|
||||
IconURL: p.Build.Avatar,
|
||||
},
|
||||
Footer: EmbedFooterObject{
|
||||
Text: "Powered by Drone Discord Plugin",
|
||||
Text: "Powered by Drone Discord Plugin",
|
||||
IconURL: "https://c1.staticflickr.com/5/4236/34957940160_435d83114f_z.jpg",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
+3
-2
@@ -26,9 +26,10 @@ func TestSendMessage(t *testing.T) {
|
||||
Number: 101,
|
||||
Status: "success",
|
||||
Link: "https://github.com/appleboy/go-hello",
|
||||
Author: "Bo-Yi Wu",
|
||||
Author: "appleboy",
|
||||
Branch: "master",
|
||||
Message: "update by drone discord plugin. \n update by drone discord plugin.",
|
||||
Event: "tag",
|
||||
Message: "update by drone discord plugin. \r\n update by drone discord plugin.",
|
||||
Commit: "e7c4f0a63ceeb42a39ac7806f7b51f3f0d204fd2",
|
||||
Avatar: "https://avatars0.githubusercontent.com/u/21979?v=3&s=100",
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user