Support Send with New Sticker.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2016-10-09 09:56:31 +08:00
parent 6cdfb8ba10
commit 57468ba50b
5 changed files with 16 additions and 1 deletions

View File

@ -15,7 +15,7 @@
* [ ] Send with New Location.
* [ ] Send with New Venue.
* [ ] Send with New Video.
* [ ] Send with New Sticker.
* [x] Send with New Sticker.
## Build
@ -60,6 +60,7 @@ docker run --rm \
-e PLUGIN_MESSAGE=test \
-e PLUGIN_PHOTO=tests/github.png \
-e PLUGIN_DOCUMENT=tests/gophercolor.png \
-e PLUGIN_STICKER=tests/github-logo.png \
-e PLUGIN_DEBUG=true \
-e PLUGIN_FORMAT=markdown \
-e DRONE_REPO_OWNER=appleboy \

View File

@ -42,6 +42,11 @@ func main() {
Usage: "send document message",
EnvVar: "PLUGIN_DOCUMENT",
},
cli.StringSliceFlag{
Name: "sticker",
Usage: "send sticker message",
EnvVar: "PLUGIN_STICKER",
},
cli.BoolFlag{
Name: "debug",
Usage: "enable debug message",
@ -133,6 +138,7 @@ func run(c *cli.Context) error {
Message: c.StringSlice("message"),
Photo: c.StringSlice("photo"),
Document: c.StringSlice("document"),
Sticker: c.StringSlice("sticker"),
Format: c.String("format"),
},
}

View File

@ -38,6 +38,7 @@ type (
Message []string
Photo []string
Document []string
Sticker []string
Format string
}
@ -122,6 +123,7 @@ func (p Plugin) Exec() error {
ids := parseID(p.Config.To)
photos := fileExist(trimElement(p.Config.Photo))
documents := fileExist(trimElement(p.Config.Document))
stickers := fileExist(trimElement(p.Config.Sticker))
// send message.
for _, user := range ids {
@ -140,6 +142,11 @@ func (p Plugin) Exec() error {
msg := tgbotapi.NewDocumentUpload(user, value)
p.Send(bot, msg)
}
for _, value := range stickers {
msg := tgbotapi.NewStickerUpload(user, value)
p.Send(bot, msg)
}
}
return nil

View File

@ -71,6 +71,7 @@ func TestSendMessage(t *testing.T) {
Message: []string{"Test Telegram Chat Bot From Travis or Local", " "},
Photo: []string{"tests/github.png", "1234", " "},
Document: []string{"tests/gophercolor.png", "1234", " "},
Sticker: []string{"tests/github-logo.png", "tests/github.png", "1234", " "},
Debug: false,
},
}

BIN
tests/github-logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB