Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'web/service')
-rw-r--r--web/service/tgbot.go46
1 files changed, 30 insertions, 16 deletions
diff --git a/web/service/tgbot.go b/web/service/tgbot.go
index 0b5a8158..7bd6a179 100644
--- a/web/service/tgbot.go
+++ b/web/service/tgbot.go
@@ -1568,30 +1568,44 @@ func (t *Tgbot) sendBanLogs(chatId int64, dt bool) {
file, err := os.Open(xray.GetIPLimitBannedPrevLogPath())
if err == nil {
- document := tu.Document(
- tu.ID(chatId),
- tu.File(file),
- )
- _, err = bot.SendDocument(document)
- if err != nil {
- logger.Error("Error in uploading backup: ", err)
+ // Check if the file is non-empty before attempting to upload
+ fileInfo, _ := file.Stat()
+ if fileInfo.Size() > 0 {
+ document := tu.Document(
+ tu.ID(chatId),
+ tu.File(file),
+ )
+ _, err = bot.SendDocument(document)
+ if err != nil {
+ logger.Error("Error in uploading IPLimitBannedPrevLog: ", err)
+ }
+ } else {
+ logger.Warning("IPLimitBannedPrevLog file is empty, not uploading.")
}
+ file.Close()
} else {
- logger.Error("Error in opening db file for backup: ", err)
+ logger.Error("Error in opening IPLimitBannedPrevLog file for backup: ", err)
}
file, err = os.Open(xray.GetIPLimitBannedLogPath())
if err == nil {
- document := tu.Document(
- tu.ID(chatId),
- tu.File(file),
- )
- _, err = bot.SendDocument(document)
- if err != nil {
- logger.Error("Error in uploading config.json: ", err)
+ // Check if the file is non-empty before attempting to upload
+ fileInfo, _ := file.Stat()
+ if fileInfo.Size() > 0 {
+ document := tu.Document(
+ tu.ID(chatId),
+ tu.File(file),
+ )
+ _, err = bot.SendDocument(document)
+ if err != nil {
+ logger.Error("Error in uploading IPLimitBannedLog: ", err)
+ }
+ } else {
+ logger.Warning("IPLimitBannedLog file is empty, not uploading.")
}
+ file.Close()
} else {
- logger.Error("Error in opening config.json file for backup: ", err)
+ logger.Error("Error in opening IPLimitBannedLog file for backup: ", err)
}
}