Support Audio message.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
57468ba50b
commit
8c0a2a65dc
@ -9,7 +9,7 @@
|
||||
* [x] Send with Text Message. (`markdown` or `html` format)
|
||||
* [x] Send with New Photo.
|
||||
* [x] Send with New Document.
|
||||
* [ ] Send with New Audio.
|
||||
* [x] Send with New Audio.
|
||||
* [ ] Send with New Voice.
|
||||
* [ ] Send with New Contact.
|
||||
* [ ] Send with New Location.
|
||||
@ -61,6 +61,7 @@ docker run --rm \
|
||||
-e PLUGIN_PHOTO=tests/github.png \
|
||||
-e PLUGIN_DOCUMENT=tests/gophercolor.png \
|
||||
-e PLUGIN_STICKER=tests/github-logo.png \
|
||||
-e PLUGIN_AUDIO=tests/audio.mp3 \
|
||||
-e PLUGIN_DEBUG=true \
|
||||
-e PLUGIN_FORMAT=markdown \
|
||||
-e DRONE_REPO_OWNER=appleboy \
|
||||
|
6
main.go
6
main.go
@ -47,6 +47,11 @@ func main() {
|
||||
Usage: "send sticker message",
|
||||
EnvVar: "PLUGIN_STICKER",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "audio",
|
||||
Usage: "send audio message",
|
||||
EnvVar: "PLUGIN_AUDIO",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "debug",
|
||||
Usage: "enable debug message",
|
||||
@ -139,6 +144,7 @@ func run(c *cli.Context) error {
|
||||
Photo: c.StringSlice("photo"),
|
||||
Document: c.StringSlice("document"),
|
||||
Sticker: c.StringSlice("sticker"),
|
||||
Audio: c.StringSlice("audio"),
|
||||
Format: c.String("format"),
|
||||
},
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ type (
|
||||
Photo []string
|
||||
Document []string
|
||||
Sticker []string
|
||||
Audio []string
|
||||
Format string
|
||||
}
|
||||
|
||||
@ -124,6 +125,7 @@ func (p Plugin) Exec() error {
|
||||
photos := fileExist(trimElement(p.Config.Photo))
|
||||
documents := fileExist(trimElement(p.Config.Document))
|
||||
stickers := fileExist(trimElement(p.Config.Sticker))
|
||||
audios := fileExist(trimElement(p.Config.Audio))
|
||||
|
||||
// send message.
|
||||
for _, user := range ids {
|
||||
@ -147,6 +149,12 @@ func (p Plugin) Exec() error {
|
||||
msg := tgbotapi.NewStickerUpload(user, value)
|
||||
p.Send(bot, msg)
|
||||
}
|
||||
|
||||
for _, value := range audios {
|
||||
msg := tgbotapi.NewAudioUpload(user, value)
|
||||
msg.Title = "Audio Message."
|
||||
p.Send(bot, msg)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -72,6 +72,7 @@ func TestSendMessage(t *testing.T) {
|
||||
Photo: []string{"tests/github.png", "1234", " "},
|
||||
Document: []string{"tests/gophercolor.png", "1234", " "},
|
||||
Sticker: []string{"tests/github-logo.png", "tests/github.png", "1234", " "},
|
||||
Audio: []string{"tests/audio.mp3", "tests/github.png", "1234", " "},
|
||||
Debug: false,
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user