1
0
mirror of https://github.com/nikoksr/notify.git synced 2024-11-24 08:22:18 +02:00

refactor(telegram): simplify telegram.AddReceivers function

Since AddReceivers no longer belongs to the notify.Notifier interface
its no longer forced to use a variadic string array as its main
parameter which needed to be parsed to an int64 array internally. The
telegram.AddReceivers now takes a variadic int64 array as parameter.
This commit is contained in:
Niko Köser 2021-02-10 15:11:32 +01:00
parent bd82278932
commit ecdfb6f1cf
No known key found for this signature in database
GPG Key ID: F3F28C118DAA6375

View File

@ -1,8 +1,6 @@
package telegram package telegram
import ( import (
"strconv"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api" tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -34,13 +32,8 @@ func New(apiToken string) (*Telegram, error) {
// AddReceivers takes Telegram chat IDs and adds them to the internal chat ID list. The Send method will send // AddReceivers takes Telegram chat IDs and adds them to the internal chat ID list. The Send method will send
// a given message to all those chats. // a given message to all those chats.
func (t *Telegram) AddReceivers(chatIDs ...string) { func (t *Telegram) AddReceivers(chatIDs ...int64) {
for _, v := range chatIDs { t.chatIDs = append(t.chatIDs, chatIDs...)
chatID, err := strconv.ParseInt(v, 10, 64)
if err == nil {
t.chatIDs = append(t.chatIDs, chatID)
}
}
} }
// Send takes a message subject and a message body and sends them to all previously set chats. Message body supports // Send takes a message subject and a message body and sends them to all previously set chats. Message body supports