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:
parent
bd82278932
commit
ecdfb6f1cf
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user