Skip to content

Commit

Permalink
Update tgbot locale + add I18nBot
Browse files Browse the repository at this point in the history
  • Loading branch information
hamid-gh98 committed May 20, 2023
1 parent d9b1b20 commit 82ead05
Show file tree
Hide file tree
Showing 2 changed files with 257 additions and 194 deletions.
7 changes: 5 additions & 2 deletions web/job/check_cpu_usage.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package job

import (
"fmt"
"strconv"
"time"
"x-ui/web/service"

Expand All @@ -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)
}
}
Loading

0 comments on commit 82ead05

Please sign in to comment.