mirror of
https://github.com/krau/SaveAny-Bot.git
synced 2026-05-12 02:39:43 +08:00
perf: optimize user storage retrieval and remove unused rate limiting middleware
This commit is contained in:
@@ -1,24 +1,18 @@
|
||||
package bot
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/celestix/gotgproto/dispatcher"
|
||||
"github.com/celestix/gotgproto/ext"
|
||||
"github.com/duke-git/lancet/v2/slice"
|
||||
"github.com/gotd/contrib/middleware/floodwait"
|
||||
"github.com/gotd/contrib/middleware/ratelimit"
|
||||
"github.com/gotd/td/telegram"
|
||||
"github.com/krau/SaveAny-Bot/config"
|
||||
"golang.org/x/time/rate"
|
||||
)
|
||||
|
||||
func FloodWaitMiddleware() []telegram.Middleware {
|
||||
waiter := floodwait.NewSimpleWaiter().WithMaxRetries(5)
|
||||
ratelimiter := ratelimit.New(rate.Every(time.Millisecond*100), 5)
|
||||
return []telegram.Middleware{
|
||||
waiter,
|
||||
ratelimiter,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ func getSelectStorageMarkup(userChatID int64, fileChatID, fileMessageID int) (*t
|
||||
}
|
||||
buttons = append(buttons, &tg.KeyboardButtonCallback{
|
||||
Text: storage.Name(),
|
||||
Data: []byte(fmt.Sprintf("add %d", cbDataId)),
|
||||
Data: fmt.Appendf(nil, "add %d", cbDataId),
|
||||
})
|
||||
}
|
||||
markup := &tg.ReplyInlineMarkup{}
|
||||
|
||||
Reference in New Issue
Block a user