diff --git a/README.md b/README.md index e94454b..3ca7203 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ * [x] Send with New Voice. * [x] Send with New Location. * [ ] Send with New Venue. -* [ ] Send with New Video. +* [x] Send with New Video. * [x] Send with New Sticker. ## Build @@ -63,6 +63,7 @@ docker run --rm \ -e PLUGIN_AUDIO=tests/audio.mp3 \ -e PLUGIN_VOICE=tests/voice.ogg \ -e PLUGIN_LOCATION=24.9163213,121.1424972 \ + -e PLUGIN_VIDEO=tests/video.mp4 \ -e PLUGIN_DEBUG=true \ -e PLUGIN_FORMAT=markdown \ -e DRONE_REPO_OWNER=appleboy \ diff --git a/main.go b/main.go index f696cbe..e40d3d6 100644 --- a/main.go +++ b/main.go @@ -62,6 +62,11 @@ func main() { Usage: "send location message", EnvVar: "PLUGIN_LOCATION", }, + cli.StringSliceFlag{ + Name: "video", + Usage: "send video message", + EnvVar: "PLUGIN_VIDEO", + }, cli.BoolFlag{ Name: "debug", Usage: "enable debug message", @@ -157,6 +162,7 @@ func run(c *cli.Context) error { Audio: c.StringSlice("audio"), Voice: c.StringSlice("voice"), Location: c.StringSlice("location"), + Video: c.StringSlice("video"), Format: c.String("format"), }, } diff --git a/plugin.go b/plugin.go index a63e27f..910c7d0 100644 --- a/plugin.go +++ b/plugin.go @@ -42,6 +42,7 @@ type ( Audio []string Voice []string Location []string + Video []string Format string } @@ -164,6 +165,7 @@ func (p Plugin) Exec() error { stickers := fileExist(trimElement(p.Config.Sticker)) audios := fileExist(trimElement(p.Config.Audio)) voices := fileExist(trimElement(p.Config.Voice)) + videos := fileExist(trimElement(p.Config.Video)) locations := trimElement(p.Config.Location) // send message. @@ -200,6 +202,12 @@ func (p Plugin) Exec() error { p.Send(bot, msg) } + for _, value := range videos { + msg := tgbotapi.NewVideoUpload(user, value) + msg.Caption = "Video Message" + p.Send(bot, msg) + } + for _, value := range locations { location, empty := convertLocation(value) diff --git a/plugin_test.go b/plugin_test.go index 5a9f461..4f11c03 100644 --- a/plugin_test.go +++ b/plugin_test.go @@ -72,9 +72,10 @@ 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", " "}, - Voice: []string{"tests/voice.ogg", "tests/github.png", "1234", " "}, + Audio: []string{"tests/audio.mp3", "1234", " "}, + Voice: []string{"tests/voice.ogg", "1234", " "}, Location: []string{"24.9163213,121.1424972", "1", " "}, + Video: []string{"tests/video.mp4", "1234", " "}, Debug: false, }, } diff --git a/tests/video.mp4 b/tests/video.mp4 new file mode 100644 index 0000000..a203d0c Binary files /dev/null and b/tests/video.mp4 differ