diff options
| author | Masoud Hidden <masoud.hidden.user@gmail.com> | 2023-05-05 01:18:37 +0300 |
|---|---|---|
| committer | Masoud Hidden <masoud.hidden.user@gmail.com> | 2023-05-05 01:18:37 +0300 |
| commit | ff33539fbadacea44ecb600e8da87c67e4dee877 (patch) | |
| tree | 3d9f2ca69c61edb345599bad650971f094191a69 /web | |
| parent | 961636b5106b0503051e2e6e63bc613397f170e3 (diff) | |
Refresh button for client report in telegram bot
Added unlimited button for expire days.
Diffstat (limited to 'web')
| -rw-r--r-- | web/service/tgbot.go | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/web/service/tgbot.go b/web/service/tgbot.go index bd95bc81..73da6d9b 100644 --- a/web/service/tgbot.go +++ b/web/service/tgbot.go @@ -154,6 +154,9 @@ func (t *Tgbot) asnwerCallback(callbackQuery *tgbotapi.CallbackQuery, isAdmin bo if len(dataArray) >= 2 && len(dataArray[1]) > 0 { email := dataArray[1] switch dataArray[0] { + case "refresh_client": + t.sendCallbackAnswerTgBot(callbackQuery.ID, fmt.Sprintf("✅ %s : Refreshed successfully.", email)) + t.searchClient(callbackQuery.From.ID, email, callbackQuery.Message.MessageID) case "admin_cancel": t.sendCallbackAnswerTgBot(callbackQuery.ID, fmt.Sprintf("❌ %s : Operation canceled.", email)) t.searchClient(callbackQuery.From.ID, email, callbackQuery.Message.MessageID) @@ -177,6 +180,9 @@ func (t *Tgbot) asnwerCallback(callbackQuery *tgbotapi.CallbackQuery, isAdmin bo tgbotapi.NewInlineKeyboardButtonData("❌ Cancel Reset", "admin_cancel "+email), ), tgbotapi.NewInlineKeyboardRow( + tgbotapi.NewInlineKeyboardButtonData("♾ Unlimited", "reset_expire_days_confirm "+email+" 0"), + ), + tgbotapi.NewInlineKeyboardRow( tgbotapi.NewInlineKeyboardButtonData("1 Mounth", "reset_expire_days_confirm "+email+" 30"), tgbotapi.NewInlineKeyboardButtonData("2 Mounth", "reset_expire_days_confirm "+email+" 60"), ), @@ -199,7 +205,11 @@ func (t *Tgbot) asnwerCallback(callbackQuery *tgbotapi.CallbackQuery, isAdmin bo if !err { days, error := strconv.Atoi(dataArray[2]) if error == nil { - t.inboundService.ResetClientExpiryTimeByEmail(email, int64(-(days * 24 * 60 * 60000))) + var date int64 = 0 + if days > 0 { + date = int64(-(days * 24 * 60 * 60000)) + } + t.inboundService.ResetClientExpiryTimeByEmail(email, date) t.sendCallbackAnswerTgBot(callbackQuery.ID, fmt.Sprintf("✅ %s : Expire days reset successfully.", email)) t.searchClient(callbackQuery.From.ID, email, callbackQuery.Message.MessageID) } else { @@ -505,7 +515,10 @@ func (t *Tgbot) searchClient(chatId int64, email string, messageID ...int) { total, expiryTime) var inlineKeyboard = tgbotapi.NewInlineKeyboardMarkup( tgbotapi.NewInlineKeyboardRow( - tgbotapi.NewInlineKeyboardButtonData("🔄 Reset Traffic", "reset_traffic "+email), + tgbotapi.NewInlineKeyboardButtonData("🔄 Refresh", "refresh_client "+email), + ), + tgbotapi.NewInlineKeyboardRow( + tgbotapi.NewInlineKeyboardButtonData("📈 Reset Traffic", "reset_traffic "+email), ), tgbotapi.NewInlineKeyboardRow( tgbotapi.NewInlineKeyboardButtonData("📅 Reset Expire Days", "reset_expire_days "+email), |
