mirror of
https://github.com/appleboy/drone-discord.git
synced 2026-06-04 18:33:47 +08:00
@@ -169,11 +169,13 @@ func run(c *cli.Context) error {
|
||||
Config: Config{
|
||||
WebhookID: c.String("webhook-id"),
|
||||
WebhookToken: c.String("webhook-token"),
|
||||
Wait: c.Bool("wait"),
|
||||
Message: c.StringSlice("message"),
|
||||
Username: c.String("username"),
|
||||
AvatarURL: c.String("avatar-url"),
|
||||
TTS: c.Bool("tts"),
|
||||
},
|
||||
Form: Form{
|
||||
Wait: c.Bool("wait"),
|
||||
Username: c.String("username"),
|
||||
AvatarURL: c.String("avatar-url"),
|
||||
TTS: c.Bool("tts"),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -39,11 +39,15 @@ type (
|
||||
WebhookID string
|
||||
WebhookToken string
|
||||
Message []string
|
||||
Wait bool `json:"wait"`
|
||||
Content string `json:"content"`
|
||||
Username string `json:"username"`
|
||||
AvatarURL string `json:"avatar_url"`
|
||||
TTS bool `json:"tts"`
|
||||
}
|
||||
|
||||
// Form for the plugin.
|
||||
Form struct {
|
||||
Wait bool `json:"wait"`
|
||||
Content string `json:"content"`
|
||||
Username string `json:"username"`
|
||||
AvatarURL string `json:"avatar_url"`
|
||||
TTS bool `json:"tts"`
|
||||
}
|
||||
|
||||
// Plugin values.
|
||||
@@ -51,6 +55,7 @@ type (
|
||||
Repo Repo
|
||||
Build Build
|
||||
Config Config
|
||||
Form Form
|
||||
}
|
||||
)
|
||||
|
||||
@@ -78,9 +83,10 @@ func (p Plugin) Exec() error {
|
||||
}
|
||||
|
||||
// update content
|
||||
p.Config.Content = txt
|
||||
p.Form.Content = txt
|
||||
fmt.Println(p.Form)
|
||||
b := new(bytes.Buffer)
|
||||
json.NewEncoder(b).Encode(p.Config)
|
||||
json.NewEncoder(b).Encode(p.Form)
|
||||
_, err = http.Post(webhookURL, "application/json; charset=utf-8", b)
|
||||
|
||||
if err != nil {
|
||||
|
||||
+8
-5
@@ -56,10 +56,13 @@ func TestSendMessage(t *testing.T) {
|
||||
Config: Config{
|
||||
WebhookID: os.Getenv("WEBHOOK_ID"),
|
||||
WebhookToken: os.Getenv("WEBHOOK_TOKEN"),
|
||||
Wait: false,
|
||||
Message: []string{"test one message from drone testing", "test two message from drone testing"},
|
||||
Username: "drone-ci",
|
||||
TTS: false,
|
||||
},
|
||||
|
||||
Form: Form{
|
||||
Username: "drone-ci",
|
||||
TTS: false,
|
||||
Wait: false,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -71,8 +74,8 @@ func TestSendMessage(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
|
||||
plugin.Config.Message = []string{"I am appleboy"}
|
||||
plugin.Config.TTS = true
|
||||
plugin.Config.Wait = true
|
||||
plugin.Form.TTS = true
|
||||
plugin.Form.Wait = true
|
||||
err = plugin.Exec()
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user