mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
fix error messagesg
This commit is contained in:
parent
2c5fdce82b
commit
f2d95ac9c6
|
@ -180,7 +180,7 @@ func (app *application) DebugCommand(name string, message twitch.PrivateMessage)
|
|||
resp, err := app.uploadPaste(reply)
|
||||
if err != nil {
|
||||
app.Log.Errorln("Could not upload paste:", err)
|
||||
app.Send(message.Channel, "Something went wrong FeelsBadMan")
|
||||
app.Send(message.Channel, fmt.Sprintf("Something went wrong FeelsBadMan %v", ErrDuringPasteUpload))
|
||||
return
|
||||
}
|
||||
app.Send(message.Channel, resp)
|
||||
|
|
|
@ -33,6 +33,7 @@ func (app *application) handleCommand(message twitch.PrivateMessage) {
|
|||
// Useful to check if enough cmdParams are provided.
|
||||
msgLen := len(strings.SplitN(message.Message, " ", -2))
|
||||
|
||||
userLevel := app.GetUserLevel(message.User.ID)
|
||||
// target is the channelname the message originated from and
|
||||
// where the TwitchClient should send the response
|
||||
target := message.Channel
|
||||
|
@ -43,6 +44,7 @@ func (app *application) handleCommand(message twitch.PrivateMessage) {
|
|||
"commandName", commandName,
|
||||
"cmdParams", cmdParams,
|
||||
"msgLen", msgLen,
|
||||
"userLevel", userLevel,
|
||||
)
|
||||
|
||||
// A `commandName` is every message starting with `()`.
|
||||
|
@ -139,9 +141,13 @@ func (app *application) handleCommand(message twitch.PrivateMessage) {
|
|||
case "debug":
|
||||
switch cmdParams[1] {
|
||||
case "user":
|
||||
app.DebugUser(cmdParams[2], message)
|
||||
if userLevel >= 250 {
|
||||
app.DebugUser(cmdParams[2], message)
|
||||
}
|
||||
case "command":
|
||||
app.DebugCommand(cmdParams[2], message)
|
||||
if userLevel >= 250 {
|
||||
app.DebugCommand(cmdParams[2], message)
|
||||
}
|
||||
}
|
||||
|
||||
case "command":
|
||||
|
|
|
@ -9,4 +9,5 @@ var (
|
|||
ErrCommandLevelNotInteger = errors.New("command level must be a number")
|
||||
ErrRecordNotFound = errors.New("user not found in the database")
|
||||
ErrUserInsufficientLevel = errors.New("user has insufficient level")
|
||||
ErrDuringPasteUpload = errors.New("could not upload paste")
|
||||
)
|
||||
|
|
|
@ -42,7 +42,7 @@ func (app *application) DebugUser(login string, message twitch.PrivateMessage) {
|
|||
resp, err := app.uploadPaste(body)
|
||||
if err != nil {
|
||||
app.Log.Errorln("Could not upload paste:", err)
|
||||
app.Send(message.Channel, "Something went wrong FeelsBadMan")
|
||||
app.Send(message.Channel, fmt.Sprintf("Something went wrong FeelsBadMan %v", ErrDuringPasteUpload))
|
||||
return
|
||||
}
|
||||
app.Send(message.Channel, resp)
|
||||
|
@ -133,8 +133,8 @@ func (app *application) SetUserLastFM(lastfmUser string, message twitch.PrivateM
|
|||
}
|
||||
}
|
||||
|
||||
// GetUserLevel takes in a login name and queries the database for an entry
|
||||
// with such a name value. If there is one it returns the level value as an integer.
|
||||
// GetUserLevel takes in a twitchId and queries the database for an entry
|
||||
// with this twitchId. If there is one it returns the level value as an integer.
|
||||
// Returns 0 on an error which is the level for unregistered users.
|
||||
func (app *application) GetUserLevel(twitchId string) int {
|
||||
userLevel, err := app.Models.Users.GetLevel(twitchId)
|
||||
|
|
2
go.mod
2
go.mod
|
@ -10,13 +10,13 @@ require (
|
|||
github.com/rs/zerolog v1.29.1
|
||||
github.com/shkh/lastfm-go v0.0.0-20191215035245-89a801c244e0
|
||||
go.uber.org/zap v1.24.0
|
||||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
|
||||
)
|
||||
|
||||
require (
|
||||
go.uber.org/atomic v1.7.0 // indirect
|
||||
go.uber.org/multierr v1.6.0 // indirect
|
||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
||||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df // indirect
|
||||
)
|
||||
|
||||
require (
|
||||
|
|
Loading…
Reference in a new issue