From c7be0ead7643ece23e9fe5a6591d1828c466783a Mon Sep 17 00:00:00 2001 From: divyam234 <47589864+divyam234@users.noreply.github.com> Date: Sat, 10 Aug 2024 00:19:16 +0530 Subject: [PATCH] refactor: check bot limits with total bots --- pkg/services/file.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/services/file.go b/pkg/services/file.go index 1bd0bd6..75a4f46 100644 --- a/pkg/services/file.go +++ b/pkg/services/file.go @@ -750,7 +750,7 @@ func (fs *FileService) GetFileStream(c *gin.Context, download bool) { multiThreads = 0 } else if fs.cnf.TG.DisableBgBots && len(tokens) > 0 { - fs.botWorker.Set(tokens, file.ChannelID) + fs.botWorker.Set(tokens[0:min(len(tokens), fs.cnf.TG.Stream.BotsLimit)], file.ChannelID) token, _ = fs.botWorker.Next(file.ChannelID) client, err = tgc.BotClient(c, fs.kv, &fs.cnf.TG, token) if err != nil { @@ -758,7 +758,7 @@ func (fs *FileService) GetFileStream(c *gin.Context, download bool) { } multiThreads = 0 } else { - fs.worker.Set(tokens[0:fs.cnf.TG.Stream.BotsLimit], file.ChannelID) + fs.worker.Set(tokens[0:min(len(tokens), fs.cnf.TG.Stream.BotsLimit)], file.ChannelID) c, err := fs.worker.Next(file.ChannelID) if err != nil { fs.handleError(err, w)