Support Video Message.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
3f25341c8b
commit
b52dcfe9c2
@ -13,7 +13,7 @@
|
|||||||
* [x] Send with New Voice.
|
* [x] Send with New Voice.
|
||||||
* [x] Send with New Location.
|
* [x] Send with New Location.
|
||||||
* [ ] Send with New Venue.
|
* [ ] Send with New Venue.
|
||||||
* [ ] Send with New Video.
|
* [x] Send with New Video.
|
||||||
* [x] Send with New Sticker.
|
* [x] Send with New Sticker.
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
@ -63,6 +63,7 @@ docker run --rm \
|
|||||||
-e PLUGIN_AUDIO=tests/audio.mp3 \
|
-e PLUGIN_AUDIO=tests/audio.mp3 \
|
||||||
-e PLUGIN_VOICE=tests/voice.ogg \
|
-e PLUGIN_VOICE=tests/voice.ogg \
|
||||||
-e PLUGIN_LOCATION=24.9163213,121.1424972 \
|
-e PLUGIN_LOCATION=24.9163213,121.1424972 \
|
||||||
|
-e PLUGIN_VIDEO=tests/video.mp4 \
|
||||||
-e PLUGIN_DEBUG=true \
|
-e PLUGIN_DEBUG=true \
|
||||||
-e PLUGIN_FORMAT=markdown \
|
-e PLUGIN_FORMAT=markdown \
|
||||||
-e DRONE_REPO_OWNER=appleboy \
|
-e DRONE_REPO_OWNER=appleboy \
|
||||||
|
6
main.go
6
main.go
@ -62,6 +62,11 @@ func main() {
|
|||||||
Usage: "send location message",
|
Usage: "send location message",
|
||||||
EnvVar: "PLUGIN_LOCATION",
|
EnvVar: "PLUGIN_LOCATION",
|
||||||
},
|
},
|
||||||
|
cli.StringSliceFlag{
|
||||||
|
Name: "video",
|
||||||
|
Usage: "send video message",
|
||||||
|
EnvVar: "PLUGIN_VIDEO",
|
||||||
|
},
|
||||||
cli.BoolFlag{
|
cli.BoolFlag{
|
||||||
Name: "debug",
|
Name: "debug",
|
||||||
Usage: "enable debug message",
|
Usage: "enable debug message",
|
||||||
@ -157,6 +162,7 @@ func run(c *cli.Context) error {
|
|||||||
Audio: c.StringSlice("audio"),
|
Audio: c.StringSlice("audio"),
|
||||||
Voice: c.StringSlice("voice"),
|
Voice: c.StringSlice("voice"),
|
||||||
Location: c.StringSlice("location"),
|
Location: c.StringSlice("location"),
|
||||||
|
Video: c.StringSlice("video"),
|
||||||
Format: c.String("format"),
|
Format: c.String("format"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ type (
|
|||||||
Audio []string
|
Audio []string
|
||||||
Voice []string
|
Voice []string
|
||||||
Location []string
|
Location []string
|
||||||
|
Video []string
|
||||||
Format string
|
Format string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,6 +165,7 @@ func (p Plugin) Exec() error {
|
|||||||
stickers := fileExist(trimElement(p.Config.Sticker))
|
stickers := fileExist(trimElement(p.Config.Sticker))
|
||||||
audios := fileExist(trimElement(p.Config.Audio))
|
audios := fileExist(trimElement(p.Config.Audio))
|
||||||
voices := fileExist(trimElement(p.Config.Voice))
|
voices := fileExist(trimElement(p.Config.Voice))
|
||||||
|
videos := fileExist(trimElement(p.Config.Video))
|
||||||
locations := trimElement(p.Config.Location)
|
locations := trimElement(p.Config.Location)
|
||||||
|
|
||||||
// send message.
|
// send message.
|
||||||
@ -200,6 +202,12 @@ func (p Plugin) Exec() error {
|
|||||||
p.Send(bot, msg)
|
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 {
|
for _, value := range locations {
|
||||||
location, empty := convertLocation(value)
|
location, empty := convertLocation(value)
|
||||||
|
|
||||||
|
@ -72,9 +72,10 @@ func TestSendMessage(t *testing.T) {
|
|||||||
Photo: []string{"tests/github.png", "1234", " "},
|
Photo: []string{"tests/github.png", "1234", " "},
|
||||||
Document: []string{"tests/gophercolor.png", "1234", " "},
|
Document: []string{"tests/gophercolor.png", "1234", " "},
|
||||||
Sticker: []string{"tests/github-logo.png", "tests/github.png", "1234", " "},
|
Sticker: []string{"tests/github-logo.png", "tests/github.png", "1234", " "},
|
||||||
Audio: []string{"tests/audio.mp3", "tests/github.png", "1234", " "},
|
Audio: []string{"tests/audio.mp3", "1234", " "},
|
||||||
Voice: []string{"tests/voice.ogg", "tests/github.png", "1234", " "},
|
Voice: []string{"tests/voice.ogg", "1234", " "},
|
||||||
Location: []string{"24.9163213,121.1424972", "1", " "},
|
Location: []string{"24.9163213,121.1424972", "1", " "},
|
||||||
|
Video: []string{"tests/video.mp4", "1234", " "},
|
||||||
Debug: false,
|
Debug: false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
BIN
tests/video.mp4
Normal file
BIN
tests/video.mp4
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user