Compare commits
No commits in common. "5e132e935008682b601f4f4726a917ee2eefc6dd" and "6dbb4b173567cbb60b47092df4aa0181cc053ca5" have entirely different histories.
5e132e9350
...
6dbb4b1735
30
.drone.yml
30
.drone.yml
@ -73,7 +73,7 @@ steps:
|
|||||||
pull: always
|
pull: always
|
||||||
image: golang:1.15
|
image: golang:1.15
|
||||||
commands:
|
commands:
|
||||||
- go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/amd64/drone-telegram
|
- "go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/amd64/drone-telegram"
|
||||||
environment:
|
environment:
|
||||||
CGO_ENABLED: 0
|
CGO_ENABLED: 0
|
||||||
when:
|
when:
|
||||||
@ -85,7 +85,7 @@ steps:
|
|||||||
pull: always
|
pull: always
|
||||||
image: golang:1.15
|
image: golang:1.15
|
||||||
commands:
|
commands:
|
||||||
- go build -v -ldflags '-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/amd64/drone-telegram
|
- "go build -v -ldflags '-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/amd64/drone-telegram"
|
||||||
environment:
|
environment:
|
||||||
CGO_ENABLED: 0
|
CGO_ENABLED: 0
|
||||||
when:
|
when:
|
||||||
@ -133,8 +133,8 @@ steps:
|
|||||||
trigger:
|
trigger:
|
||||||
ref:
|
ref:
|
||||||
- refs/heads/master
|
- refs/heads/master
|
||||||
- refs/pull/**
|
- "refs/pull/**"
|
||||||
- refs/tags/**
|
- "refs/tags/**"
|
||||||
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- testing
|
- testing
|
||||||
@ -152,7 +152,7 @@ steps:
|
|||||||
pull: always
|
pull: always
|
||||||
image: golang:1.15
|
image: golang:1.15
|
||||||
commands:
|
commands:
|
||||||
- go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm64/drone-telegram
|
- "go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm64/drone-telegram"
|
||||||
environment:
|
environment:
|
||||||
CGO_ENABLED: 0
|
CGO_ENABLED: 0
|
||||||
when:
|
when:
|
||||||
@ -164,7 +164,7 @@ steps:
|
|||||||
pull: always
|
pull: always
|
||||||
image: golang:1.15
|
image: golang:1.15
|
||||||
commands:
|
commands:
|
||||||
- go build -v -ldflags '-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm64/drone-telegram
|
- "go build -v -ldflags '-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm64/drone-telegram"
|
||||||
environment:
|
environment:
|
||||||
CGO_ENABLED: 0
|
CGO_ENABLED: 0
|
||||||
when:
|
when:
|
||||||
@ -212,8 +212,8 @@ steps:
|
|||||||
trigger:
|
trigger:
|
||||||
ref:
|
ref:
|
||||||
- refs/heads/master
|
- refs/heads/master
|
||||||
- refs/pull/**
|
- "refs/pull/**"
|
||||||
- refs/tags/**
|
- "refs/tags/**"
|
||||||
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- testing
|
- testing
|
||||||
@ -231,7 +231,7 @@ steps:
|
|||||||
pull: always
|
pull: always
|
||||||
image: golang:1.15
|
image: golang:1.15
|
||||||
commands:
|
commands:
|
||||||
- go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm/drone-telegram
|
- "go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm/drone-telegram"
|
||||||
environment:
|
environment:
|
||||||
CGO_ENABLED: 0
|
CGO_ENABLED: 0
|
||||||
when:
|
when:
|
||||||
@ -243,7 +243,7 @@ steps:
|
|||||||
pull: always
|
pull: always
|
||||||
image: golang:1.15
|
image: golang:1.15
|
||||||
commands:
|
commands:
|
||||||
- go build -v -ldflags '-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm/drone-telegram
|
- "go build -v -ldflags '-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm/drone-telegram"
|
||||||
environment:
|
environment:
|
||||||
CGO_ENABLED: 0
|
CGO_ENABLED: 0
|
||||||
when:
|
when:
|
||||||
@ -291,8 +291,8 @@ steps:
|
|||||||
trigger:
|
trigger:
|
||||||
ref:
|
ref:
|
||||||
- refs/heads/master
|
- refs/heads/master
|
||||||
- refs/pull/**
|
- "refs/pull/**"
|
||||||
- refs/tags/**
|
- "refs/tags/**"
|
||||||
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- testing
|
- testing
|
||||||
@ -322,14 +322,14 @@ steps:
|
|||||||
api_key:
|
api_key:
|
||||||
from_secret: github_release_api_key
|
from_secret: github_release_api_key
|
||||||
files:
|
files:
|
||||||
- dist/release/*
|
- "dist/release/*"
|
||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
- tag
|
- tag
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
ref:
|
ref:
|
||||||
- refs/tags/**
|
- "refs/tags/**"
|
||||||
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- testing
|
- testing
|
||||||
@ -367,7 +367,7 @@ steps:
|
|||||||
trigger:
|
trigger:
|
||||||
ref:
|
ref:
|
||||||
- refs/heads/master
|
- refs/heads/master
|
||||||
- refs/tags/**
|
- "refs/tags/**"
|
||||||
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- linux-amd64
|
- linux-amd64
|
||||||
|
4
DOCS.md
4
DOCS.md
@ -122,7 +122,7 @@ Example configuration with video message:
|
|||||||
+ - tests/video2.mp4
|
+ - tests/video2.mp4
|
||||||
```
|
```
|
||||||
|
|
||||||
Example configuration with message format (`Markdown` or `HTML`), default as `Markdown`:
|
Example configuration with message format:
|
||||||
|
|
||||||
```diff
|
```diff
|
||||||
- name: send telegram notification
|
- name: send telegram notification
|
||||||
@ -130,7 +130,7 @@ Example configuration with message format (`Markdown` or `HTML`), default as `Ma
|
|||||||
settings:
|
settings:
|
||||||
token: xxxxxxxxxx
|
token: xxxxxxxxxx
|
||||||
to: telegram_user_id
|
to: telegram_user_id
|
||||||
+ format: Markdown
|
+ format: markdown
|
||||||
```
|
```
|
||||||
|
|
||||||
Example configuration with a custom message template:
|
Example configuration with a custom message template:
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
[![codecov](https://codecov.io/gh/appleboy/drone-telegram/branch/master/graph/badge.svg)](https://codecov.io/gh/appleboy/drone-telegram)
|
[![codecov](https://codecov.io/gh/appleboy/drone-telegram/branch/master/graph/badge.svg)](https://codecov.io/gh/appleboy/drone-telegram)
|
||||||
[![Go Report Card](https://goreportcard.com/badge/github.com/appleboy/drone-telegram)](https://goreportcard.com/report/github.com/appleboy/drone-telegram)
|
[![Go Report Card](https://goreportcard.com/badge/github.com/appleboy/drone-telegram)](https://goreportcard.com/report/github.com/appleboy/drone-telegram)
|
||||||
[![Docker Pulls](https://img.shields.io/docker/pulls/appleboy/drone-telegram.svg)](https://hub.docker.com/r/appleboy/drone-telegram/)
|
[![Docker Pulls](https://img.shields.io/docker/pulls/appleboy/drone-telegram.svg)](https://hub.docker.com/r/appleboy/drone-telegram/)
|
||||||
|
[![microbadger](https://images.microbadger.com/badges/image/appleboy/drone-telegram.svg)](https://microbadger.com/images/appleboy/drone-telegram "Get your own image badge on microbadger.com")
|
||||||
|
|
||||||
[Drone](https://github.com/drone/drone) plugin for sending telegram notifications. For the usage
|
[Drone](https://github.com/drone/drone) plugin for sending telegram notifications. For the usage
|
||||||
information and a listing of the available options please take a look at [the docs](http://plugins.drone.io/appleboy/drone-telegram/).
|
information and a listing of the available options please take a look at [the docs](http://plugins.drone.io/appleboy/drone-telegram/).
|
||||||
|
33
go.mod
33
go.mod
@ -1,32 +1,13 @@
|
|||||||
module github.com/appleboy/drone-telegram
|
module github.com/appleboy/drone-telegram
|
||||||
|
|
||||||
go 1.20
|
go 1.15
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.belvedersky.ru/common/tgbotapi v0.6.0
|
github.com/drone/drone-template-lib v1.0.0
|
||||||
github.com/appleboy/drone-template-lib v1.0.1-0.20210703043441-92442f23f605
|
github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible
|
||||||
github.com/joho/godotenv v1.5.1
|
github.com/joho/godotenv v1.3.0
|
||||||
github.com/stretchr/testify v1.8.3
|
github.com/stretchr/testify v1.7.0
|
||||||
github.com/urfave/cli v1.22.13
|
|
||||||
)
|
|
||||||
|
|
||||||
require (
|
|
||||||
github.com/Masterminds/goutils v1.1.0 // indirect
|
|
||||||
github.com/Masterminds/semver/v3 v3.1.0 // indirect
|
|
||||||
github.com/Masterminds/sprig/v3 v3.1.0 // indirect
|
|
||||||
github.com/aymerick/raymond v2.0.2+incompatible // indirect
|
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
|
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
|
||||||
github.com/google/uuid v1.1.1 // indirect
|
|
||||||
github.com/huandu/xstrings v1.3.1 // indirect
|
|
||||||
github.com/imdario/mergo v0.3.8 // indirect
|
|
||||||
github.com/mitchellh/copystructure v1.0.0 // indirect
|
|
||||||
github.com/mitchellh/reflectwalk v1.0.0 // indirect
|
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
|
||||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
|
||||||
github.com/spf13/cast v1.3.1 // indirect
|
|
||||||
github.com/stretchr/objx v0.5.0 // indirect
|
|
||||||
github.com/technoweenie/multipartstreamer v1.0.1 // indirect
|
github.com/technoweenie/multipartstreamer v1.0.1 // indirect
|
||||||
golang.org/x/crypto v0.0.0-20200414173820-0848c9571904 // indirect
|
github.com/urfave/cli v1.20.0
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||||
)
|
)
|
||||||
|
83
go.sum
83
go.sum
@ -1,62 +1,45 @@
|
|||||||
git.belvedersky.ru/common/tgbotapi v0.6.0 h1:meq8GNNKG8XADYXO1legSs4vLpBxzXXy2BHk5VSDB1U=
|
|
||||||
git.belvedersky.ru/common/tgbotapi v0.6.0/go.mod h1:UeXhGrHhZUA9PEwMgOkdCBDRW5e7EJkmUte/xMELiVI=
|
|
||||||
github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
|
||||||
github.com/Masterminds/goutils v1.1.0 h1:zukEsf/1JZwCMgHiK3GZftabmxiCw4apj3a28RPBiVg=
|
github.com/Masterminds/goutils v1.1.0 h1:zukEsf/1JZwCMgHiK3GZftabmxiCw4apj3a28RPBiVg=
|
||||||
github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
|
github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
|
||||||
github.com/Masterminds/semver/v3 v3.1.0 h1:Y2lUDsFKVRSYGojLJ1yLxSXdMmMYTYls0rCvoqmMUQk=
|
github.com/Masterminds/semver v1.4.2 h1:WBLTQ37jOCzSLtXNdoo8bNM8876KhNqOKvrlGITgsTc=
|
||||||
github.com/Masterminds/semver/v3 v3.1.0/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
|
github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
|
||||||
github.com/Masterminds/sprig/v3 v3.1.0 h1:j7GpgZ7PdFqNsmncycTHsLmVPf5/3wJtlgW9TNDYD9Y=
|
github.com/Masterminds/sprig v2.18.0+incompatible h1:QoGhlbC6pter1jxKnjMFxT8EqsLuDE6FEcNbWEpw+lI=
|
||||||
github.com/Masterminds/sprig/v3 v3.1.0/go.mod h1:ONGMf7UfYGAbMXCZmQLy8x3lCDIPrEZE/rU8pmrbihA=
|
github.com/Masterminds/sprig v2.18.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=
|
||||||
github.com/appleboy/drone-template-lib v1.0.1-0.20210703043441-92442f23f605 h1:13DCA0YYotNdiFodfoWpMVBi4bBTv3OxO2o/IU60kuw=
|
|
||||||
github.com/appleboy/drone-template-lib v1.0.1-0.20210703043441-92442f23f605/go.mod h1:Mdr1SPt42qahB+Gfb/QBsQID+tkBkzrR+j+Gwq9XMBs=
|
|
||||||
github.com/aymerick/raymond v2.0.2+incompatible h1:VEp3GpgdAnv9B2GFyTvqgcKvY+mfKMjPOA3SbKLtnU0=
|
github.com/aymerick/raymond v2.0.2+incompatible h1:VEp3GpgdAnv9B2GFyTvqgcKvY+mfKMjPOA3SbKLtnU0=
|
||||||
github.com/aymerick/raymond v2.0.2+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
|
github.com/aymerick/raymond v2.0.2+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
|
github.com/bouk/monkey v1.0.0 h1:k6z8fLlPhETfn5l9rlWVE7Q6B23DoaqosTdArvNQRdc=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
github.com/bouk/monkey v1.0.0/go.mod h1:PG/63f4XEUlVyW1ttIeOJmJhhe1+t9EC/je3eTjvFhE=
|
||||||
|
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/drone/drone-template-lib v1.0.0 h1:PNBBfUhifRnrPCoWBlTitk3jipXdv8u8WLbIf7h7j00=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/drone/drone-template-lib v1.0.0/go.mod h1:Hqy1tgqPH5mtbFOZmow19l4jOkZvp+WZ00cB4W3MJhg=
|
||||||
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
|
github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible h1:2cauKuaELYAEARXRkq2LrJ0yDDv1rW7+wrTEdVL3uaU=
|
||||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible/go.mod h1:qf9acutJ8cwBUhm1bqgz6Bei9/C/c93FPDljKWwsOgM=
|
||||||
github.com/huandu/xstrings v1.3.1 h1:4jgBlKK6tLKFvO8u5pmYjG91cqytmDCDvGh7ECVFfFs=
|
github.com/google/uuid v1.1.0 h1:Jf4mxPC/ziBnoPIdpQdPJ9OeiomAUHLvxmPRSPH9m4s=
|
||||||
github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
|
github.com/google/uuid v1.1.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/imdario/mergo v0.3.8 h1:CGgOkSJeqMRmt0D9XLWExdT4m4F1vd3FV3VPt+0VxkQ=
|
github.com/huandu/xstrings v1.2.0 h1:yPeWdRnmynF7p+lLYz0H2tthW9lqhMJrQV/U7yy4wX0=
|
||||||
github.com/imdario/mergo v0.3.8/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4=
|
||||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI=
|
||||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||||
github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ=
|
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
|
||||||
github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw=
|
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
||||||
github.com/mitchellh/reflectwalk v1.0.0 h1:9D+8oIskB4VJBN5SFlmc27fSlIBZaov1Wpk/IfikLNY=
|
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
|
||||||
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
|
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
|
||||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
|
||||||
github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng=
|
|
||||||
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/technoweenie/multipartstreamer v1.0.1 h1:XRztA5MXiR1TIRHxH2uNxXxaIkKQDeX7m2XsSOlQEnM=
|
||||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
|
||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
|
||||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
|
||||||
github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY=
|
|
||||||
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
|
||||||
github.com/technoweenie/multipartstreamer v1.0.1/go.mod h1:jNVxdtShOxzAsukZwTSw6MDx5eUJoiEBsSvzDU9uzog=
|
github.com/technoweenie/multipartstreamer v1.0.1/go.mod h1:jNVxdtShOxzAsukZwTSw6MDx5eUJoiEBsSvzDU9uzog=
|
||||||
github.com/urfave/cli v1.22.13 h1:wsLILXG8qCJNse/qAgLNf23737Cx05GflHg/PJGe1Ok=
|
github.com/tkuchiki/faketime v0.0.0-20170607100027-a4500a4f4643 h1:ii/sHfgFMByozryLeiDmn1ClZ/Pena4NgpJ4P7UuX9o=
|
||||||
github.com/urfave/cli v1.22.13/go.mod h1:VufqObjsMTF2BBwKawpx9R8eAneNEWhoO0yx8Vd+FkE=
|
github.com/tkuchiki/faketime v0.0.0-20170607100027-a4500a4f4643/go.mod h1:RXY/TXAwGGL36IKDjrHFMcjpUrEiyWSEtLhFPw3UWF0=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw=
|
||||||
golang.org/x/crypto v0.0.0-20200414173820-0848c9571904 h1:bXoxMPcSLOq08zI3/c5dEBT6lE4eh+jOh886GHrn6V8=
|
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
||||||
golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67 h1:ng3VDlRp5/DHpSWl02R4rM9I+8M2rhmsuLwAMmkLQWE=
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
||||||
|
2
main.go
2
main.go
@ -122,7 +122,7 @@ func main() {
|
|||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "format",
|
Name: "format",
|
||||||
Value: formatMarkdown,
|
Value: formatMarkdown,
|
||||||
Usage: "telegram message format (Markdown or HTML)",
|
Usage: "telegram message format",
|
||||||
EnvVar: "PLUGIN_FORMAT,FORMAT,INPUT_FORMAT",
|
EnvVar: "PLUGIN_FORMAT,FORMAT,INPUT_FORMAT",
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
|
28
plugin.go
28
plugin.go
@ -15,13 +15,12 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
tgbotapi "git.belvedersky.ru/common/tgbotapi"
|
"github.com/drone/drone-template-lib/template"
|
||||||
"github.com/appleboy/drone-template-lib/template"
|
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
formatMarkdown = "Markdown"
|
formatMarkdown = "markdown"
|
||||||
formatHTML = "HTML"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
@ -260,10 +259,6 @@ func parseTo(to []string, authorEmail string, matchEmail bool) []int64 {
|
|||||||
return ids
|
return ids
|
||||||
}
|
}
|
||||||
|
|
||||||
func templateMessage(t string, plugin Plugin) (string, error) {
|
|
||||||
return template.RenderTrim(t, plugin)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Exec executes the plugin.
|
// Exec executes the plugin.
|
||||||
func (p Plugin) Exec() (err error) {
|
func (p Plugin) Exec() (err error) {
|
||||||
if len(p.Config.Token) == 0 || len(p.Config.To) == 0 {
|
if len(p.Config.Token) == 0 || len(p.Config.To) == 0 {
|
||||||
@ -318,7 +313,7 @@ func (p Plugin) Exec() (err error) {
|
|||||||
var bot *tgbotapi.BotAPI
|
var bot *tgbotapi.BotAPI
|
||||||
if len(p.Config.Socks5) > 0 {
|
if len(p.Config.Socks5) > 0 {
|
||||||
proxyClient := &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)}}
|
proxyClient := &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)}}
|
||||||
bot, err = tgbotapi.NewBotAPIWithClient(p.Config.Token, "", proxyClient) // ANCHOR ENDPOINT
|
bot, err = tgbotapi.NewBotAPIWithClient(p.Config.Token, proxyClient)
|
||||||
} else {
|
} else {
|
||||||
bot, err = tgbotapi.NewBotAPI(p.Config.Token)
|
bot, err = tgbotapi.NewBotAPI(p.Config.Token)
|
||||||
}
|
}
|
||||||
@ -361,7 +356,7 @@ func (p Plugin) Exec() (err error) {
|
|||||||
// send message.
|
// send message.
|
||||||
for _, user := range ids {
|
for _, user := range ids {
|
||||||
for _, value := range message {
|
for _, value := range message {
|
||||||
txt, err := templateMessage(value, p)
|
txt, err := template.RenderTrim(value, p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -372,35 +367,34 @@ func (p Plugin) Exec() (err error) {
|
|||||||
msg.ParseMode = p.Config.Format
|
msg.ParseMode = p.Config.Format
|
||||||
msg.DisableWebPagePreview = p.Config.DisableWebPagePreview
|
msg.DisableWebPagePreview = p.Config.DisableWebPagePreview
|
||||||
msg.DisableNotification = p.Config.DisableNotification
|
msg.DisableNotification = p.Config.DisableNotification
|
||||||
|
|
||||||
if err := p.Send(bot, msg); err != nil {
|
if err := p.Send(bot, msg); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, value := range photos {
|
for _, value := range photos {
|
||||||
msg := tgbotapi.NewPhoto(user, tgbotapi.FilePath(value))
|
msg := tgbotapi.NewPhotoUpload(user, value)
|
||||||
if err := p.Send(bot, msg); err != nil {
|
if err := p.Send(bot, msg); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, value := range documents {
|
for _, value := range documents {
|
||||||
msg := tgbotapi.NewDocument(user, tgbotapi.FilePath(value))
|
msg := tgbotapi.NewDocumentUpload(user, value)
|
||||||
if err := p.Send(bot, msg); err != nil {
|
if err := p.Send(bot, msg); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, value := range stickers {
|
for _, value := range stickers {
|
||||||
msg := tgbotapi.NewSticker(user, tgbotapi.FilePath(value))
|
msg := tgbotapi.NewStickerUpload(user, value)
|
||||||
if err := p.Send(bot, msg); err != nil {
|
if err := p.Send(bot, msg); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, value := range audios {
|
for _, value := range audios {
|
||||||
msg := tgbotapi.NewAudio(user, tgbotapi.FilePath(value))
|
msg := tgbotapi.NewAudioUpload(user, value)
|
||||||
msg.Title = "Audio Message."
|
msg.Title = "Audio Message."
|
||||||
if err := p.Send(bot, msg); err != nil {
|
if err := p.Send(bot, msg); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -408,14 +402,14 @@ func (p Plugin) Exec() (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, value := range voices {
|
for _, value := range voices {
|
||||||
msg := tgbotapi.NewVoice(user, tgbotapi.FilePath(value))
|
msg := tgbotapi.NewVoiceUpload(user, value)
|
||||||
if err := p.Send(bot, msg); err != nil {
|
if err := p.Send(bot, msg); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, value := range videos {
|
for _, value := range videos {
|
||||||
msg := tgbotapi.NewVideo(user, tgbotapi.FilePath(value))
|
msg := tgbotapi.NewVideoUpload(user, value)
|
||||||
msg.Caption = "Video Message"
|
msg.Caption = "Video Message"
|
||||||
if err := p.Send(bot, msg); err != nil {
|
if err := p.Send(bot, msg); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -3,9 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/appleboy/drone-template-lib/template"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -353,7 +351,7 @@ func TestHTMLMessage(t *testing.T) {
|
|||||||
Sha: "e7c4f0a63ceeb42a39ac7806f7b51f3f0d204fd2",
|
Sha: "e7c4f0a63ceeb42a39ac7806f7b51f3f0d204fd2",
|
||||||
Author: "Bo-Yi Wu",
|
Author: "Bo-Yi Wu",
|
||||||
Branch: "master",
|
Branch: "master",
|
||||||
Message: "test",
|
Message: "Freakin' macOS isn't fully case-sensitive..",
|
||||||
},
|
},
|
||||||
Build: Build{
|
Build: Build{
|
||||||
Number: 101,
|
Number: 101,
|
||||||
@ -364,20 +362,11 @@ func TestHTMLMessage(t *testing.T) {
|
|||||||
Config: Config{
|
Config: Config{
|
||||||
Token: os.Getenv("TELEGRAM_TOKEN"),
|
Token: os.Getenv("TELEGRAM_TOKEN"),
|
||||||
To: []string{os.Getenv("TELEGRAM_TO")},
|
To: []string{os.Getenv("TELEGRAM_TO")},
|
||||||
Message: `
|
|
||||||
Test HTML Format
|
|
||||||
<a href='https://google.com'>Google .com 1</a>
|
|
||||||
<a href='https://google.com'>Google .com 2</a>
|
|
||||||
<a href='https://google.com'>Google .com 3</a>
|
|
||||||
`,
|
|
||||||
Format: formatHTML,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.Nil(t, plugin.Exec())
|
err := plugin.Exec()
|
||||||
|
assert.Nil(t, err)
|
||||||
plugin.Config.MessageFile = "tests/message_html.txt"
|
|
||||||
assert.Nil(t, plugin.Exec())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMessageFile(t *testing.T) {
|
func TestMessageFile(t *testing.T) {
|
||||||
@ -396,8 +385,6 @@ func TestMessageFile(t *testing.T) {
|
|||||||
Number: 101,
|
Number: 101,
|
||||||
Status: "success",
|
Status: "success",
|
||||||
Link: "https://github.com/appleboy/go-hello",
|
Link: "https://github.com/appleboy/go-hello",
|
||||||
Started: time.Now().Unix(),
|
|
||||||
Finished: time.Now().Add(time.Duration(180 * time.Second)).Unix(),
|
|
||||||
},
|
},
|
||||||
|
|
||||||
Config: Config{
|
Config: Config{
|
||||||
@ -427,8 +414,6 @@ func TestTemplateVars(t *testing.T) {
|
|||||||
Number: 101,
|
Number: 101,
|
||||||
Status: "success",
|
Status: "success",
|
||||||
Link: "https://github.com/appleboy/go-hello",
|
Link: "https://github.com/appleboy/go-hello",
|
||||||
Started: time.Now().Unix(),
|
|
||||||
Finished: time.Now().Add(time.Duration(180 * time.Second)).Unix(),
|
|
||||||
},
|
},
|
||||||
|
|
||||||
Config: Config{
|
Config: Config{
|
||||||
@ -507,31 +492,3 @@ func TestProxySendMessage(t *testing.T) {
|
|||||||
err := plugin.Exec()
|
err := plugin.Exec()
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBuildTemplate(t *testing.T) {
|
|
||||||
plugin := Plugin{
|
|
||||||
Commit: Commit{
|
|
||||||
Sha: "e7c4f0a63ceeb42a39ac7806f7b51f3f0d204fd2",
|
|
||||||
Author: "Bo-Yi Wu",
|
|
||||||
Branch: "master",
|
|
||||||
Message: "This is a test commit msg",
|
|
||||||
},
|
|
||||||
Build: Build{
|
|
||||||
Number: 101,
|
|
||||||
Status: "success",
|
|
||||||
Link: "https://github.com/appleboy/go-hello",
|
|
||||||
Started: time.Now().Unix(),
|
|
||||||
Finished: time.Now().Add(time.Duration(180 * time.Second)).Unix(),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err := template.RenderTrim(
|
|
||||||
`
|
|
||||||
Sample message loaded from file.
|
|
||||||
|
|
||||||
Commit msg: {{uppercasefirst commit.message}}
|
|
||||||
|
|
||||||
duration: {{duration build.started build.finished}}
|
|
||||||
`, plugin)
|
|
||||||
assert.Nil(t, err)
|
|
||||||
}
|
|
||||||
|
@ -2,4 +2,3 @@ Sample message loaded from file.
|
|||||||
|
|
||||||
Commit msg: {{commit.message}}
|
Commit msg: {{commit.message}}
|
||||||
|
|
||||||
duration: {{duration build.started build.finished}}
|
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
Test HTML Format from file
|
|
||||||
<a href='https://google.com'>Google .com 1</a>
|
|
||||||
<a href='https://google.com'>Google .com 2</a>
|
|
||||||
<a href='https://google.com'>Google .com 3</a>
|
|
||||||
<a href='https://google.com'>Google .com 4</a>
|
|
@ -5,4 +5,3 @@ Sample message template loaded from file.
|
|||||||
|
|
||||||
Commit msg: {{commit.message}}
|
Commit msg: {{commit.message}}
|
||||||
|
|
||||||
duration: {{duration build.started build.finished}}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user