Support Send with New Sticker.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
6cdfb8ba10
commit
57468ba50b
@ -15,7 +15,7 @@
|
|||||||
* [ ] Send with New Location.
|
* [ ] Send with New Location.
|
||||||
* [ ] Send with New Venue.
|
* [ ] Send with New Venue.
|
||||||
* [ ] Send with New Video.
|
* [ ] Send with New Video.
|
||||||
* [ ] Send with New Sticker.
|
* [x] Send with New Sticker.
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
@ -60,6 +60,7 @@ docker run --rm \
|
|||||||
-e PLUGIN_MESSAGE=test \
|
-e PLUGIN_MESSAGE=test \
|
||||||
-e PLUGIN_PHOTO=tests/github.png \
|
-e PLUGIN_PHOTO=tests/github.png \
|
||||||
-e PLUGIN_DOCUMENT=tests/gophercolor.png \
|
-e PLUGIN_DOCUMENT=tests/gophercolor.png \
|
||||||
|
-e PLUGIN_STICKER=tests/github-logo.png \
|
||||||
-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
@ -42,6 +42,11 @@ func main() {
|
|||||||
Usage: "send document message",
|
Usage: "send document message",
|
||||||
EnvVar: "PLUGIN_DOCUMENT",
|
EnvVar: "PLUGIN_DOCUMENT",
|
||||||
},
|
},
|
||||||
|
cli.StringSliceFlag{
|
||||||
|
Name: "sticker",
|
||||||
|
Usage: "send sticker message",
|
||||||
|
EnvVar: "PLUGIN_STICKER",
|
||||||
|
},
|
||||||
cli.BoolFlag{
|
cli.BoolFlag{
|
||||||
Name: "debug",
|
Name: "debug",
|
||||||
Usage: "enable debug message",
|
Usage: "enable debug message",
|
||||||
@ -133,6 +138,7 @@ func run(c *cli.Context) error {
|
|||||||
Message: c.StringSlice("message"),
|
Message: c.StringSlice("message"),
|
||||||
Photo: c.StringSlice("photo"),
|
Photo: c.StringSlice("photo"),
|
||||||
Document: c.StringSlice("document"),
|
Document: c.StringSlice("document"),
|
||||||
|
Sticker: c.StringSlice("sticker"),
|
||||||
Format: c.String("format"),
|
Format: c.String("format"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@ type (
|
|||||||
Message []string
|
Message []string
|
||||||
Photo []string
|
Photo []string
|
||||||
Document []string
|
Document []string
|
||||||
|
Sticker []string
|
||||||
Format string
|
Format string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,6 +123,7 @@ func (p Plugin) Exec() error {
|
|||||||
ids := parseID(p.Config.To)
|
ids := parseID(p.Config.To)
|
||||||
photos := fileExist(trimElement(p.Config.Photo))
|
photos := fileExist(trimElement(p.Config.Photo))
|
||||||
documents := fileExist(trimElement(p.Config.Document))
|
documents := fileExist(trimElement(p.Config.Document))
|
||||||
|
stickers := fileExist(trimElement(p.Config.Sticker))
|
||||||
|
|
||||||
// send message.
|
// send message.
|
||||||
for _, user := range ids {
|
for _, user := range ids {
|
||||||
@ -140,6 +142,11 @@ func (p Plugin) Exec() error {
|
|||||||
msg := tgbotapi.NewDocumentUpload(user, value)
|
msg := tgbotapi.NewDocumentUpload(user, value)
|
||||||
p.Send(bot, msg)
|
p.Send(bot, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, value := range stickers {
|
||||||
|
msg := tgbotapi.NewStickerUpload(user, value)
|
||||||
|
p.Send(bot, msg)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -71,6 +71,7 @@ func TestSendMessage(t *testing.T) {
|
|||||||
Message: []string{"Test Telegram Chat Bot From Travis or Local", " "},
|
Message: []string{"Test Telegram Chat Bot From Travis or Local", " "},
|
||||||
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", " "},
|
||||||
Debug: false,
|
Debug: false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
BIN
tests/github-logo.png
Normal file
BIN
tests/github-logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 46 KiB |
Loading…
Reference in New Issue
Block a user