|
@@ -770,7 +770,10 @@ func (t *Tgbot) asnwerCallback(callbackQuery *telego.CallbackQuery, isAdmin bool
|
|
|
switch callbackQuery.Data {
|
|
|
case "get_usage":
|
|
|
t.sendCallbackAnswerTgBot(callbackQuery.ID, t.I18nBot("tgbot.buttons.serverUsage"))
|
|
|
- t.SendMsgToTgbot(chatId, t.getServerUsage())
|
|
|
+ t.getServerUsage(chatId)
|
|
|
+ case "usage_refresh":
|
|
|
+ t.sendCallbackAnswerTgBot(callbackQuery.ID, t.I18nBot("tgbot.answers.successfulOperation"))
|
|
|
+ t.getServerUsage(chatId, callbackQuery.Message.GetMessageID())
|
|
|
case "inbounds":
|
|
|
t.sendCallbackAnswerTgBot(callbackQuery.ID, t.I18nBot("tgbot.buttons.getInbounds"))
|
|
|
t.SendMsgToTgbot(chatId, t.getInboundUsages())
|
|
@@ -916,7 +919,7 @@ func (t *Tgbot) SendReport() {
|
|
|
t.SendMsgToTgbotAdmins(msg)
|
|
|
}
|
|
|
|
|
|
- info := t.getServerUsage()
|
|
|
+ info := t.sendServerUsage()
|
|
|
t.SendMsgToTgbotAdmins(info)
|
|
|
|
|
|
t.sendExhaustedToAdmins()
|
|
@@ -946,7 +949,28 @@ func (t *Tgbot) sendExhaustedToAdmins() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func (t *Tgbot) getServerUsage() string {
|
|
|
+func (t *Tgbot) getServerUsage(chatId int64, messageID ...int) string {
|
|
|
+ info := t.prepareServerUsageInfo()
|
|
|
+
|
|
|
+ keyboard := tu.InlineKeyboard(tu.InlineKeyboardRow(
|
|
|
+ tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.refresh")).WithCallbackData(t.encodeQuery("usage_refresh"))))
|
|
|
+
|
|
|
+ if len(messageID) > 0 {
|
|
|
+ t.editMessageTgBot(chatId, messageID[0], info, keyboard)
|
|
|
+ } else {
|
|
|
+ t.SendMsgToTgbot(chatId, info, keyboard)
|
|
|
+ }
|
|
|
+
|
|
|
+ return info
|
|
|
+}
|
|
|
+
|
|
|
+// Send server usage without an inline keyborad
|
|
|
+func (t *Tgbot) sendServerUsage() string {
|
|
|
+ info := t.prepareServerUsageInfo()
|
|
|
+ return info
|
|
|
+}
|
|
|
+
|
|
|
+func (t *Tgbot) prepareServerUsageInfo() string {
|
|
|
info, ipv4, ipv6 := "", "", ""
|
|
|
|
|
|
// get latest status of server
|