Skip to content

Commit

Permalink
Merge branch 'release/v44.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
alaingilbert committed May 3, 2021
2 parents 8f22ce2 + b53990d commit df70460
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 8 deletions.
5 changes: 5 additions & 0 deletions cmd/ogamed/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@ func start(c *cli.Context) error {
e.GET("/bot/is-vacation-mode", ogame.IsVacationModeHandler)
e.GET("/bot/user-infos", ogame.GetUserInfosHandler)
e.GET("/bot/character-class", ogame.GetCharacterClassHandler)
e.GET("/bot/has-commander", ogame.HasCommanderHandler)
e.GET("/bot/has-admiral", ogame.HasAdmiralHandler)
e.GET("/bot/has-engineer", ogame.HasEngineerHandler)
e.GET("/bot/has-geologist", ogame.HasGeologistHandler)
e.GET("/bot/has-technocrat", ogame.HasTechnocratHandler)
e.POST("/bot/send-message", ogame.SendMessageHandler)
e.GET("/bot/fleets", ogame.GetFleetsHandler)
e.GET("/bot/fleets/slots", ogame.GetSlotsHandler)
Expand Down
35 changes: 35 additions & 0 deletions handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,41 @@ func GetCharacterClassHandler(c echo.Context) error {
return c.JSON(http.StatusOK, SuccessResp(bot.CharacterClass()))
}

// HasCommanderHandler ...
func HasCommanderHandler(c echo.Context) error {
bot := c.Get("bot").(*OGame)
hasCommander := bot.hasCommander
return c.JSON(http.StatusOK, SuccessResp(hasCommander))
}

// HasAdmiralHandler ...
func HasAdmiralHandler(c echo.Context) error {
bot := c.Get("bot").(*OGame)
hasAdmiral := bot.hasAdmiral
return c.JSON(http.StatusOK, SuccessResp(hasAdmiral))
}

// HasCommanderHandler ...
func HasEngineerHandler(c echo.Context) error {
bot := c.Get("bot").(*OGame)
hasEngineer := bot.hasEngineer
return c.JSON(http.StatusOK, SuccessResp(hasEngineer))
}

// HasGeologistHandler ...
func HasGeologistHandler(c echo.Context) error {
bot := c.Get("bot").(*OGame)
hasGeologist := bot.hasGeologist
return c.JSON(http.StatusOK, SuccessResp(hasGeologist))
}

// HasTechnocratHandler ...
func HasTechnocratHandler(c echo.Context) error {
bot := c.Get("bot").(*OGame)
hasTechnocrat := bot.hasTechnocrat
return c.JSON(http.StatusOK, SuccessResp(hasTechnocrat))
}

// GetEspionageReportMessagesHandler ...
func GetEspionageReportMessagesHandler(c echo.Context) error {
bot := c.Get("bot").(*OGame)
Expand Down
16 changes: 8 additions & 8 deletions ogame.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func Register(lobby, email, password, challengeID, lang string, client *http.Cli
Error string `json:"error"`
}
if err := json.Unmarshal(by, &res); err != nil {
return err
return errors.New(err.Error() + " : " + string(by))
}
if res.Error != "" {
return errors.New(res.Error)
Expand Down Expand Up @@ -347,7 +347,7 @@ func RedeemCode(lobby, email, password, otpSecret, token string, client *http.Cl
return errors.New("invalid request, token invalid ?")
}
if err := json.Unmarshal(by, &respParsed); err != nil {
return err
return errors.New(err.Error() + " : " + string(by))
}
if respParsed.TokenType != "accountTrading" {
return errors.New("tokenType is not accountTrading")
Expand Down Expand Up @@ -408,7 +408,7 @@ func AddAccount(lobby, username, password, otpSecret, universe, lang string, cli
return newAccount, errors.New("invalid request, account already in lobby ?")
}
if err := json.Unmarshal(by, &newAccount); err != nil {
return newAccount, err
return newAccount, errors.New(err.Error() + " : " + string(by))
}
if newAccount.Error != "" {
return newAccount, errors.New(newAccount.Error)
Expand Down Expand Up @@ -585,7 +585,7 @@ func getUserAccounts(b *OGame, token string) ([]account, error) {
}
b.bytesUploaded += req.ContentLength
if err := json.Unmarshal(by, &userAccounts); err != nil {
return userAccounts, err
return userAccounts, errors.New("failed to get user accounts : " + err.Error() + " : " + string(by))
}
return userAccounts, nil
}
Expand All @@ -607,7 +607,7 @@ func getServers2(lobby string, client *http.Client) ([]Server, error) {
return servers, err
}
if err := json.Unmarshal(by, &servers); err != nil {
return servers, err
return servers, errors.New("failed to get servers : " + err.Error() + " : " + string(by))
}
return servers, nil
}
Expand Down Expand Up @@ -635,7 +635,7 @@ func getServers(b *OGame) ([]Server, error) {
}
b.bytesUploaded += req.ContentLength
if err := json.Unmarshal(by, &servers); err != nil {
return servers, err
return servers, errors.New("failed to get servers : " + err.Error() + " : " + string(by))
}
return servers, nil
}
Expand Down Expand Up @@ -754,7 +754,7 @@ func getLoginLink(b *OGame, userAccount account, token string) (string, error) {
URL string
}
if err := json.Unmarshal(by, &loginLink); err != nil {
return "", err
return "", errors.New("failed to get login link : " + err.Error() + " : " + string(by))
}
return loginLink.URL, nil
}
Expand Down Expand Up @@ -4540,7 +4540,7 @@ func (b *OGame) addAccount(number int, lang string) (NewAccount, error) {
b.bytesUploaded += req.ContentLength
b.bytesDownloaded += int64(len(by))
if err := json.Unmarshal(by, &newAccount); err != nil {
return newAccount, err
return newAccount, errors.New(err.Error() + " : " + string(by))
}
return newAccount, nil
}
Expand Down

0 comments on commit df70460

Please sign in to comment.