From 80c3f84eacb36cdc8395eb2cbc942c7cd24c48ae Mon Sep 17 00:00:00 2001 From: Alireza Ahmadi Date: Sun, 10 Mar 2024 15:29:03 +0100 Subject: [PATCH] small changes --- README.md | 3 +-- main.go | 2 +- web/controller/inbound.go | 8 ++++---- web/service/inbound.go | 2 +- web/service/tgbot.go | 4 ++-- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 7badfa5f..b54984a3 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,7 @@ **If you think this project is helpful to you, you may wish to give a**:star2: -image +[!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/alireza7) - USDT (TRC20): `TYTq73Gj6dJ67qe58JVPD9zpjW2cc9XgVz` - Tezos (XTZ): diff --git a/main.go b/main.go index d2264596..b1327486 100644 --- a/main.go +++ b/main.go @@ -318,7 +318,7 @@ func main() { updateTgbotEnableSts(enabletgbot) } default: - fmt.Println("except 'run' or 'setting' subcommands") + fmt.Println("Invalid subcommands") fmt.Println() runCmd.Usage() fmt.Println() diff --git a/web/controller/inbound.go b/web/controller/inbound.go index 4be7b454..eeb8e120 100644 --- a/web/controller/inbound.go +++ b/web/controller/inbound.go @@ -148,7 +148,7 @@ func (a *InboundController) addInboundClient(c *gin.Context) { return } jsonMsg(c, "Client(s) added", nil) - if err == nil && needRestart { + if needRestart { a.xrayService.SetToNeedRestart() } } @@ -169,7 +169,7 @@ func (a *InboundController) delInboundClient(c *gin.Context) { return } jsonMsg(c, "Client deleted", nil) - if err == nil && needRestart { + if needRestart { a.xrayService.SetToNeedRestart() } } @@ -192,7 +192,7 @@ func (a *InboundController) updateInboundClient(c *gin.Context) { return } jsonMsg(c, "Client updated", nil) - if err == nil && needRestart { + if needRestart { a.xrayService.SetToNeedRestart() } } @@ -213,7 +213,7 @@ func (a *InboundController) resetClientTraffic(c *gin.Context) { return } jsonMsg(c, "traffic reseted", nil) - if err == nil && needRestart { + if needRestart { a.xrayService.SetToNeedRestart() } } diff --git a/web/service/inbound.go b/web/service/inbound.go index dab991ee..c9e27051 100644 --- a/web/service/inbound.go +++ b/web/service/inbound.go @@ -941,7 +941,7 @@ func (s *InboundService) disableInvalidInbounds(tx *gorm.DB) (bool, int64, error s.xrayApi.Init(p.GetAPIPort()) for _, tag := range tags { err1 := s.xrayApi.DelInbound(tag) - if err == nil { + if err1 == nil { logger.Debug("Inbound disabled by api:", tag) } else { logger.Debug("Error in disabling inbound by api:", err1) diff --git a/web/service/tgbot.go b/web/service/tgbot.go index 7c8d4683..573cf876 100644 --- a/web/service/tgbot.go +++ b/web/service/tgbot.go @@ -132,7 +132,7 @@ func (t *Tgbot) OnReceive() { isAdmin := checkAdmin(tgId) if update.Message == nil { if update.CallbackQuery != nil { - t.asnwerCallback(update.CallbackQuery, isAdmin) + t.asnwerCallback(update.CallbackQuery) } } else { if update.Message.IsCommand() { @@ -193,7 +193,7 @@ func (t *Tgbot) answerCommand(message *tgbotapi.Message, chatId int64, isAdmin b t.SendAnswer(chatId, msg, isAdmin) } -func (t *Tgbot) asnwerCallback(callbackQuery *tgbotapi.CallbackQuery, isAdmin bool) { +func (t *Tgbot) asnwerCallback(callbackQuery *tgbotapi.CallbackQuery) { // Respond to the callback query, telling Telegram to show the user // a message with the data received. callback := tgbotapi.NewCallback(callbackQuery.ID, callbackQuery.Data)