diff --git a/.golangci.yml b/.golangci.yml index f98ccb2..25af2a8 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -9,9 +9,11 @@ linters: enable: - dupl - exportloopref + - gocyclo - godox - gofmt - goimports + - golint - govet - misspell - prealloc diff --git a/actions.go b/actions.go index a97994c..c7abb8f 100644 --- a/actions.go +++ b/actions.go @@ -104,12 +104,12 @@ func (bot *IGopher) sendMessageWebDriver(user, message string) (bool, error) { return false, errors.New("Error during user searching") } randomSleep() - if usernames, err := bot.SeleniumStruct.WebDriver.FindElements(selenium.ByXPATH, "//div[@aria-labelledby]/div/span//img[@data-testid='user-avatar']"); err != nil { + usernames, err := bot.SeleniumStruct.WebDriver.FindElements(selenium.ByXPATH, "//div[@aria-labelledby]/div/span//img[@data-testid='user-avatar']") + if err != nil { return false, errors.New("Error during user selection") - } else { - usernames[0].Click() - log.Debug("User to dm selected") } + usernames[0].Click() + log.Debug("User to dm selected") } else { return false, errors.New("Error during user selection") } diff --git a/config.go b/config.go index 629648b..f1974f8 100644 --- a/config.go +++ b/config.go @@ -167,19 +167,19 @@ func CheckConfigValidity() error { config := ImportConfig() validate := validator.New() if err := validate.Struct(config.Account); err != nil { - return errors.New("Invalid credentials format! Please check your settings.\n\n") + return errors.New("Invalid credentials format! Please check your settings") } if err := validate.Struct(config.SrcUsers); err != nil { - return errors.New("Invalid scrapper configuration! Please check your settings.\n\n") + return errors.New("Invalid scrapper configuration! Please check your settings") } if err := validate.Struct(config.AutoDm); err != nil { - return errors.New("Invalid autodm module configuration! Please check your settings.\n\n") + return errors.New("Invalid autodm module configuration! Please check your settings") } return nil } -// Read config yml file and initialize it for use with bot +// ReadBotConfigYaml read config yml file and initialize it for use with bot func ReadBotConfigYaml() IGopher { var c IGopher file, err := ioutil.ReadFile(filepath.FromSlash("./config/config.yaml")) diff --git a/internal/tui/homePage.go b/internal/tui/homePage.go index 79ad0b2..9d5c4f4 100644 --- a/internal/tui/homePage.go +++ b/internal/tui/homePage.go @@ -33,10 +33,8 @@ func (m model) UpdateHomePage(msg tea.Msg) (model, tea.Cmd) { if err == nil { execBot = true return m, tea.Quit - } else { - errorMessage = err.Error() - break } + errorMessage = err.Error() + "\n\n" case 1: config = igopher.ImportConfig() m.screen = settingsMenu