Repository: crazy-max/diun

Issue:
[feature request] Add Telegram message option disable_notification
### Description

For telegram notify please add the option 'disable_notification' to receive messages without sound notification by setting as environment variable.
Default is on if sending bot messages, for low-level messages (at night) I would like to turn off the sound for this notify, 







Discussion:

Solution patch:
diff --git a/docs/notif/telegram.md b/docs/notif/telegram.md
index 6276e41f..12d6e709 100644
--- a/docs/notif/telegram.md
+++ b/docs/notif/telegram.md
@@ -23,13 +23,14 @@ Multiple chat IDs can be provided in order to deliver notifications to multiple
           Docker tag {{ .Entry.Image }} which you subscribed to through {{ .Entry.Provider }} provider has been released.
     ```
 
-| Name               | Default                            | Description                                                               |
-|--------------------|------------------------------------|---------------------------------------------------------------------------|
-| `token`            |                                    | Telegram bot token                                                        |
-| `tokenFile`        |                                    | Use content of secret file as Telegram bot token if `token` not defined   |
-| `chatIDs`          |                                    | List of [chat IDs](#chatids-format) to send notifications to              |
-| `chatIDsFile`      |                                    | Use content of secret file as chat IDs if `chatIDs` not defined           |
-| `templateBody`[^1] | See [below](#default-templatebody) | [Notification template](../faq.md#notification-template) for message body |
+| Name                  | Default                            | Description                                                               |
+|-----------------------|------------------------------------|---------------------------------------------------------------------------|
+| `token`               |                                    | Telegram bot token                                                        |
+| `tokenFile`           |                                    | Use content of secret file as Telegram bot token if `token` not defined   |
+| `chatIDs`             |                                    | List of [chat IDs](#chatids-format) to send notifications to              |
+| `chatIDsFile`         |                                    | Use content of secret file as chat IDs if `chatIDs` not defined           |
+| `templateBody`[^1]    | See [below](#default-templatebody) | [Notification template](../faq.md#notification-template) for message body |
+| `disableNotification` | `false`                            | Send silent message with no sound                                         |
 
 !!! abstract "Environment variables"
     * `DIUN_NOTIF_TELEGRAM_TOKEN`
@@ -37,6 +38,7 @@ Multiple chat IDs can be provided in order to deliver notifications to multiple
     * `DIUN_NOTIF_TELEGRAM_CHATIDS` (comma separated)
     * `DIUN_NOTIF_TELEGRAM_CHATIDSFILE`
     * `DIUN_NOTIF_TELEGRAM_TEMPLATEBODY`
+    * `DIUN_NOTIF_TELEGRAM_DISABLENOTIFICATION`
 
 !!! example "chat IDs secret file"
     Chat IDs secret file must be a valid JSON array like: `["123456789","987654321","567891234:25","891256734:25;12"]`
diff --git a/internal/model/notif_telegram.go b/internal/model/notif_telegram.go
index 33fe58a1..d4d13e32 100644
--- a/internal/model/notif_telegram.go
+++ b/internal/model/notif_telegram.go
@@ -1,15 +1,18 @@
 package model
 
+import "github.com/crazy-max/diun/v4/pkg/utl"
+
 // NotifTelegramDefaultTemplateBody ...
 const NotifTelegramDefaultTemplateBody = `Docker tag {{ if .Entry.Image.HubLink }}[{{ .Entry.Image }}]({{ .Entry.Image.HubLink }}){{ else }}{{ .Entry.Image }}{{ end }} which you subscribed to through {{ .Entry.Provider }} provider {{ if (eq .Entry.Status "new") }}is available{{ else }}has been updated{{ end }} on {{ .Entry.Image.Domain }} registry (triggered by {{ escapeMarkdown .Meta.Hostname }} host).`
 
 // NotifTelegram holds Telegram notification configuration details
 type NotifTelegram struct {
-	Token        string   `yaml:"token,omitempty" json:"token,omitempty" validate:"omitempty"`
-	TokenFile    string   `yaml:"tokenFile,omitempty" json:"tokenFile,omitempty" validate:"omitempty,file"`
-	ChatIDs      []string `yaml:"chatIDs,omitempty" json:"chatIDs,omitempty" validate:"omitempty"`
-	ChatIDsFile  string   `yaml:"chatIDsFile,omitempty" json:"chatIDsFile,omitempty" validate:"omitempty,file"`
-	TemplateBody string   `yaml:"templateBody,omitempty" json:"templateBody,omitempty" validate:"required"`
+	Token               string   `yaml:"token,omitempty" json:"token,omitempty" validate:"omitempty"`
+	TokenFile           string   `yaml:"tokenFile,omitempty" json:"tokenFile,omitempty" validate:"omitempty,file"`
+	ChatIDs             []string `yaml:"chatIDs,omitempty" json:"chatIDs,omitempty" validate:"omitempty"`
+	ChatIDsFile         string   `yaml:"chatIDsFile,omitempty" json:"chatIDsFile,omitempty" validate:"omitempty,file"`
+	TemplateBody        string   `yaml:"templateBody,omitempty" json:"templateBody,omitempty" validate:"required"`
+	DisableNotification *bool    `yaml:"disableNotification,omitempty" json:"disableNotification,omitempty" validate:"omitempty"`
 }
 
 // GetDefaults gets the default values
@@ -22,4 +25,5 @@ func (s *NotifTelegram) GetDefaults() *NotifTelegram {
 // SetDefaults sets the default values
 func (s *NotifTelegram) SetDefaults() {
 	s.TemplateBody = NotifTelegramDefaultTemplateBody
+	s.DisableNotification = utl.NewFalse()
 }
diff --git a/internal/notif/telegram/client.go b/internal/notif/telegram/client.go
index c1329e5c..6bbadec5 100644
--- a/internal/notif/telegram/client.go
+++ b/internal/notif/telegram/client.go
@@ -107,12 +107,12 @@ func (c *Client) Send(entry model.NotifEntry) error {
 	for _, cid := range parsedChatIDs {
 		if len(cid.topics) > 0 {
 			for _, topic := range cid.topics {
-				if err = sendTelegramMessage(bot, cid.id, topic, string(body)); err != nil {
+				if err = sendTelegramMessage(bot, cid.id, topic, string(body), *c.cfg.DisableNotification); err != nil {
 					return err
 				}
 			}
 		} else {
-			if err = sendTelegramMessage(bot, cid.id, 0, string(body)); err != nil {
+			if err = sendTelegramMessage(bot, cid.id, 0, string(body), *c.cfg.DisableNotification); err != nil {
 				return err
 			}
 		}
@@ -151,11 +151,12 @@ func parseChatIDs(entries []string) ([]chatID, error) {
 	return chatIDs, nil
 }
 
-func sendTelegramMessage(bot *gotgbot.Bot, chatID int64, threadID int64, message string) error {
+func sendTelegramMessage(bot *gotgbot.Bot, chatID int64, threadID int64, message string, disableNotification bool) error {
 	_, err := bot.SendMessage(chatID, message, &gotgbot.SendMessageOpts{
-		MessageThreadId:    threadID,
-		ParseMode:          gotgbot.ParseModeMarkdown,
-		LinkPreviewOptions: &gotgbot.LinkPreviewOptions{IsDisabled: true},
+		MessageThreadId:     threadID,
+		ParseMode:           gotgbot.ParseModeMarkdown,
+		LinkPreviewOptions:  &gotgbot.LinkPreviewOptions{IsDisabled: true},
+		DisableNotification: disableNotification,
 	})
 	return err
 }



Test patch:
diff --git a/internal/config/config_test.go b/internal/config/config_test.go
index 472708a6..d3b0a5d4 100644
--- a/internal/config/config_test.go
+++ b/internal/config/config_test.go
@@ -189,7 +189,8 @@ for <code>{{ .Entry.Manifest.Platform }}</code> platform.
 							"567891234:25",
 							"891256734:25;12",
 						},
-						TemplateBody: model.NotifTelegramDefaultTemplateBody,
+						TemplateBody:        model.NotifTelegramDefaultTemplateBody,
+						DisableNotification: utl.NewFalse(),
 					},
 					Webhook: &model.NotifWebhook{
 						Endpoint: "http://webhook.foo.com/sd54qad89azd5a",
@@ -351,7 +352,8 @@ func TestLoadEnv(t *testing.T) {
 							"8547439",
 							"1234567",
 						},
-						TemplateBody: model.NotifTelegramDefaultTemplateBody,
+						TemplateBody:        model.NotifTelegramDefaultTemplateBody,
+						DisableNotification: utl.NewFalse(),
 					},
 				},
 				Providers: &model.Providers{