Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'web/service')
-rw-r--r--web/service/tgbot.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/web/service/tgbot.go b/web/service/tgbot.go
index 8777cbbd..fa9ccb1d 100644
--- a/web/service/tgbot.go
+++ b/web/service/tgbot.go
@@ -61,8 +61,9 @@ func (t *Tgbot) Start(i18nFS embed.FS) error {
return err
}
- // init hash storage
- t.hashStorage = global.NewHashStorage(5*time.Minute, false)
+ // init hash storage => store callback queries
+ // NOTE: it only save the query if its length is more than 64 chars.
+ t.hashStorage = global.NewHashStorage(20*time.Minute, false)
tgBottoken, err := t.settingService.GetTgBotToken()
if err != nil || tgBottoken == "" {
@@ -199,8 +200,12 @@ func (t *Tgbot) asnwerCallback(callbackQuery *telego.CallbackQuery, isAdmin bool
chatId := callbackQuery.Message.Chat.ID
if isAdmin {
- // get query from hash storage (if the query was <= 64 chars hash storage dont save the hash and return data itself)
- decodedQuery := t.hashStorage.GetValue(callbackQuery.Data)
+ // get query from hash storage
+ decodedQuery, err := t.hashStorage.GetValue(callbackQuery.Data)
+ if err != nil {
+ t.SendMsgToTgbot(chatId, "Query not found! Please use the command again!")
+ return
+ }
dataArray := strings.Split(decodedQuery, " ")
if len(dataArray) >= 2 && len(dataArray[1]) > 0 {