add disable_notification parameter (#99)
This commit is contained in:
parent
a91d132e3f
commit
6dbb4b1735
14
DOCS.md
14
DOCS.md
@ -233,10 +233,22 @@ Disables link previews for links in this message
|
|||||||
settings:
|
settings:
|
||||||
token: xxxxxxxxxx
|
token: xxxxxxxxxx
|
||||||
to: telegram_user_id
|
to: telegram_user_id
|
||||||
message: send message using custom socks5 URL
|
message: send message without a link preview
|
||||||
+ disable_web_page_preview: true
|
+ disable_web_page_preview: true
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Disables notifications for this message
|
||||||
|
|
||||||
|
```diff
|
||||||
|
- name: send telegram notification
|
||||||
|
image: appleboy/drone-telegram
|
||||||
|
settings:
|
||||||
|
token: xxxxxxxxxx
|
||||||
|
to: telegram_user_id
|
||||||
|
message: send message message silently
|
||||||
|
+ disable_notification: true
|
||||||
|
```
|
||||||
|
|
||||||
## Parameter Reference
|
## Parameter Reference
|
||||||
|
|
||||||
token
|
token
|
||||||
|
6
main.go
6
main.go
@ -114,6 +114,11 @@ func main() {
|
|||||||
Usage: "disables link previews for links in this message",
|
Usage: "disables link previews for links in this message",
|
||||||
EnvVar: "PLUGIN_DISABLE_WEB_PAGE_PREVIEW,INPUT_DISABLE_WEB_PAGE_PREVIEW",
|
EnvVar: "PLUGIN_DISABLE_WEB_PAGE_PREVIEW,INPUT_DISABLE_WEB_PAGE_PREVIEW",
|
||||||
},
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "disable.notification",
|
||||||
|
Usage: "sends the message silently. users will receive a notification with no sound.",
|
||||||
|
EnvVar: "PLUGIN_DISABLE_NOTIFICATION,INPUT_DISABLE_NOTIFICATION",
|
||||||
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "format",
|
Name: "format",
|
||||||
Value: formatMarkdown,
|
Value: formatMarkdown,
|
||||||
@ -322,6 +327,7 @@ func run(c *cli.Context) error {
|
|||||||
Socks5: c.String("socks5"),
|
Socks5: c.String("socks5"),
|
||||||
|
|
||||||
DisableWebPagePreview: c.Bool("disable.webpage.preview"),
|
DisableWebPagePreview: c.Bool("disable.webpage.preview"),
|
||||||
|
DisableNotification: c.Bool("disable.notification"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,6 +88,7 @@ type (
|
|||||||
Socks5 string
|
Socks5 string
|
||||||
|
|
||||||
DisableWebPagePreview bool
|
DisableWebPagePreview bool
|
||||||
|
DisableNotification bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Plugin values.
|
// Plugin values.
|
||||||
@ -365,6 +366,7 @@ func (p Plugin) Exec() (err error) {
|
|||||||
msg := tgbotapi.NewMessage(user, txt)
|
msg := tgbotapi.NewMessage(user, txt)
|
||||||
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
|
||||||
if err := p.Send(bot, msg); err != nil {
|
if err := p.Send(bot, msg); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -145,6 +145,27 @@ func TestDisableWebPagePreviewMessage(t *testing.T) {
|
|||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDisableNotificationMessage(t *testing.T) {
|
||||||
|
plugin := Plugin{
|
||||||
|
Config: Config{
|
||||||
|
Token: os.Getenv("TELEGRAM_TOKEN"),
|
||||||
|
To: []string{os.Getenv("TELEGRAM_TO")},
|
||||||
|
DisableNotification: true,
|
||||||
|
Debug: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.Config.Message = "DisableNotification https://www.google.com.tw"
|
||||||
|
err := plugin.Exec()
|
||||||
|
assert.Nil(t, err)
|
||||||
|
|
||||||
|
// disable message
|
||||||
|
plugin.Config.DisableNotification = false
|
||||||
|
plugin.Config.Message = "EnableNotification https://www.google.com.tw"
|
||||||
|
err = plugin.Exec()
|
||||||
|
assert.Nil(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
func TestBotError(t *testing.T) {
|
func TestBotError(t *testing.T) {
|
||||||
plugin := Plugin{
|
plugin := Plugin{
|
||||||
Repo: Repo{
|
Repo: Repo{
|
||||||
|
Loading…
Reference in New Issue
Block a user