From 8c5648eb09b0d6d1479f102156e8a548ed478caa Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami <70919649+hamid-gh98@users.noreply.github.com> Date: Sat, 20 May 2023 20:29:28 +0430 Subject: FIX callback query and BUTTON_DATA_INVALID error with hashStorage --- web/job/check_hash_storage.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 web/job/check_hash_storage.go (limited to 'web/job') diff --git a/web/job/check_hash_storage.go b/web/job/check_hash_storage.go new file mode 100644 index 00000000..468aa2e0 --- /dev/null +++ b/web/job/check_hash_storage.go @@ -0,0 +1,19 @@ +package job + +import ( + "x-ui/web/service" +) + +type CheckHashStorageJob struct { + tgbotService service.Tgbot +} + +func NewCheckHashStorageJob() *CheckHashStorageJob { + return new(CheckHashStorageJob) +} + +// Here Run is an interface method of the Job interface +func (j *CheckHashStorageJob) Run() { + // Remove expired hashes from storage + j.tgbotService.GetHashStorage().RemoveExpiredHashes() +} -- cgit v1.2.3 From 82ead0509359aa364cc188ef7f22e74cd45fe347 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami <70919649+hamid-gh98@users.noreply.github.com> Date: Sun, 21 May 2023 03:30:26 +0430 Subject: Update tgbot locale + add I18nBot --- web/job/check_cpu_usage.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'web/job') diff --git a/web/job/check_cpu_usage.go b/web/job/check_cpu_usage.go index cfc86b60..74f6a544 100644 --- a/web/job/check_cpu_usage.go +++ b/web/job/check_cpu_usage.go @@ -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) } } -- cgit v1.2.3