From ecdfb6f1cf64ff751d7249c66bd5cd74570b7d58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niko=20K=C3=B6ser?= Date: Wed, 10 Feb 2021 15:11:32 +0100 Subject: [PATCH] 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. --- service/telegram/telegram.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/service/telegram/telegram.go b/service/telegram/telegram.go index 4c4528f..0fa4484 100644 --- a/service/telegram/telegram.go +++ b/service/telegram/telegram.go @@ -1,8 +1,6 @@ package telegram import ( - "strconv" - tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api" "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 // a given message to all those chats. -func (t *Telegram) AddReceivers(chatIDs ...string) { - for _, v := range chatIDs { - chatID, err := strconv.ParseInt(v, 10, 64) - if err == nil { - t.chatIDs = append(t.chatIDs, chatID) - } - } +func (t *Telegram) AddReceivers(chatIDs ...int64) { + t.chatIDs = append(t.chatIDs, chatIDs...) } // Send takes a message subject and a message body and sends them to all previously set chats. Message body supports