Update tgbot locale + add I18nBot

This commit is contained in:
Hamidreza Ghavami
2023-05-21 03:30:26 +04:30
parent d9b1b200ce
commit 82ead05093
2 changed files with 257 additions and 194 deletions

View File

@@ -1,7 +1,7 @@
package job
import (
"fmt"
"strconv"
"time"
"x-ui/web/service"
@@ -24,7 +24,10 @@ func (j *CheckCpuJob) Run() {
// get latest status of server
percent, err := cpu.Percent(1*time.Second, false)
if err == nil && percent[0] > float64(threshold) {
msg := fmt.Sprintf("🔴 CPU usage %.2f%% is more than threshold %d%%", percent[0], threshold)
msg := j.tgbotService.I18nBot("tgbot.messages.cpuThreshold",
"Percent=="+strconv.FormatFloat(percent[0], 'f', 2, 64),
"Threshold=="+strconv.Itoa(threshold))
j.tgbotService.SendMsgToTgbotAdmins(msg)
}
}