From 6b760c72b7f76dfcb46faa350c63d0b60ae99ce9 Mon Sep 17 00:00:00 2001 From: c9s Date: Tue, 8 Dec 2020 16:28:55 +0800 Subject: [PATCH] use bot token prefix as the redis store namespace --- pkg/notifier/telegramnotifier/telegram.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/notifier/telegramnotifier/telegram.go b/pkg/notifier/telegramnotifier/telegram.go index 2a4b7ad5f..f31e0461a 100644 --- a/pkg/notifier/telegramnotifier/telegram.go +++ b/pkg/notifier/telegramnotifier/telegram.go @@ -2,6 +2,7 @@ package telegramnotifier import ( "fmt" + "strings" log "github.com/sirupsen/logrus" tb "gopkg.in/tucnak/telebot.v2" @@ -36,7 +37,9 @@ func New(bot *tb.Bot, authToken string, options ...NotifyOption) *Notifier { o(notifier) } - store := notifier.redis.NewStore("bbgo", "telegram") + // use token prefix as the redis namespace + tt := strings.Split(bot.Token, ":") + store := notifier.redis.NewStore("bbgo", "telegram", tt[0]) if err := store.Load(notifier.chatUser) ; err == nil { bot.Send(notifier.chatUser, fmt.Sprintf("Hi %s, I'm back", notifier.chatUser.Username)) }