Support Voice Message.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
8c0a2a65dc
commit
1142360e53
@ -10,7 +10,7 @@
|
||||
* [x] Send with New Photo.
|
||||
* [x] Send with New Document.
|
||||
* [x] Send with New Audio.
|
||||
* [ ] Send with New Voice.
|
||||
* [x] Send with New Voice.
|
||||
* [ ] Send with New Contact.
|
||||
* [ ] Send with New Location.
|
||||
* [ ] Send with New Venue.
|
||||
@ -62,6 +62,7 @@ docker run --rm \
|
||||
-e PLUGIN_DOCUMENT=tests/gophercolor.png \
|
||||
-e PLUGIN_STICKER=tests/github-logo.png \
|
||||
-e PLUGIN_AUDIO=tests/audio.mp3 \
|
||||
-e PLUGIN_VOICE=tests/voice.ogg \
|
||||
-e PLUGIN_DEBUG=true \
|
||||
-e PLUGIN_FORMAT=markdown \
|
||||
-e DRONE_REPO_OWNER=appleboy \
|
||||
|
6
main.go
6
main.go
@ -52,6 +52,11 @@ func main() {
|
||||
Usage: "send audio message",
|
||||
EnvVar: "PLUGIN_AUDIO",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "voice",
|
||||
Usage: "send voice message",
|
||||
EnvVar: "PLUGIN_VOICE",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "debug",
|
||||
Usage: "enable debug message",
|
||||
@ -145,6 +150,7 @@ func run(c *cli.Context) error {
|
||||
Document: c.StringSlice("document"),
|
||||
Sticker: c.StringSlice("sticker"),
|
||||
Audio: c.StringSlice("audio"),
|
||||
Voice: c.StringSlice("voice"),
|
||||
Format: c.String("format"),
|
||||
},
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ type (
|
||||
Document []string
|
||||
Sticker []string
|
||||
Audio []string
|
||||
Voice []string
|
||||
Format string
|
||||
}
|
||||
|
||||
@ -126,6 +127,7 @@ func (p Plugin) Exec() error {
|
||||
documents := fileExist(trimElement(p.Config.Document))
|
||||
stickers := fileExist(trimElement(p.Config.Sticker))
|
||||
audios := fileExist(trimElement(p.Config.Audio))
|
||||
voices := fileExist(trimElement(p.Config.Voice))
|
||||
|
||||
// send message.
|
||||
for _, user := range ids {
|
||||
@ -155,6 +157,11 @@ func (p Plugin) Exec() error {
|
||||
msg.Title = "Audio Message."
|
||||
p.Send(bot, msg)
|
||||
}
|
||||
|
||||
for _, value := range voices {
|
||||
msg := tgbotapi.NewVoiceUpload(user, value)
|
||||
p.Send(bot, msg)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -73,6 +73,7 @@ func TestSendMessage(t *testing.T) {
|
||||
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", " "},
|
||||
Voice: []string{"tests/voice.ogg", "tests/github.png", "1234", " "},
|
||||
Debug: false,
|
||||
},
|
||||
}
|
||||
|
BIN
tests/audio.mp3
Normal file
BIN
tests/audio.mp3
Normal file
Binary file not shown.
BIN
tests/voice.ogg
Normal file
BIN
tests/voice.ogg
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user