fix return messages to use code block for usernames
This commit is contained in:
parent
00360d2ad6
commit
da284cd124
@ -51,7 +51,7 @@ var (
|
|||||||
// check requestedUsername validity
|
// check requestedUsername validity
|
||||||
valid := checkMcUsernameValid(requestedUsername)
|
valid := checkMcUsernameValid(requestedUsername)
|
||||||
if !valid {
|
if !valid {
|
||||||
simpleResponse(s, i, fmt.Sprintf("%s is not a valid minecraft username", requestedUsername))
|
simpleResponse(s, i, fmt.Sprintf("`%s` is not a valid minecraft username", requestedUsername))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,14 +60,14 @@ var (
|
|||||||
// execute RCON
|
// execute RCON
|
||||||
response, err := conn.Execute(fmt.Sprintf("whitelist add %s", requestedUsername))
|
response, err := conn.Execute(fmt.Sprintf("whitelist add %s", requestedUsername))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
simpleResponse(s, i, fmt.Sprintf("Failed to add %s to whitelist: %s", requestedUsername, err.Error()))
|
simpleResponse(s, i, fmt.Sprintf("Failed to add `%s` to whitelist: %s", requestedUsername, err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// this can happen if the username is not a real player, OR if the user is already on the whitelist
|
// this can happen if the username is not a real player, OR if the user is already on the whitelist
|
||||||
// In both cases we want to exit early to avoid adding an invalid username to the db
|
// In both cases we want to exit early to avoid adding an invalid username to the db
|
||||||
if !strings.EqualFold(response, fmt.Sprintf("Added %s to the whitelist", requestedUsername)) {
|
if !strings.EqualFold(response, fmt.Sprintf("Added %s to the whitelist", requestedUsername)) {
|
||||||
simpleResponse(s, i, fmt.Sprintf("Failed to add %s to whitelist: %s", requestedUsername, response))
|
simpleResponse(s, i, fmt.Sprintf("Failed to add `%s` to whitelist: %s", requestedUsername, response))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,9 +76,9 @@ var (
|
|||||||
SaveDB(dbPath, db)
|
SaveDB(dbPath, db)
|
||||||
|
|
||||||
// send response
|
// send response
|
||||||
simpleResponse(s, i, fmt.Sprintf("%s linked minecraft username %s", invokingUserName, requestedUsername))
|
simpleResponse(s, i, fmt.Sprintf("`%s` linked minecraft username `%s`", invokingUserName, requestedUsername))
|
||||||
} else {
|
} else {
|
||||||
simpleResponse(s, i, fmt.Sprintf("%s already has a linked minecraft username %s", invokingUserName, existingMCUsername))
|
simpleResponse(s, i, fmt.Sprintf("`%s` already has a linked minecraft username `%s`", invokingUserName, existingMCUsername))
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -88,18 +88,18 @@ var (
|
|||||||
|
|
||||||
existingMCUsername, ok := db[invokingUserID]
|
existingMCUsername, ok := db[invokingUserID]
|
||||||
if !ok { // invoking user does not currently have an mc username associated
|
if !ok { // invoking user does not currently have an mc username associated
|
||||||
simpleResponse(s, i, fmt.Sprintf("%s does not have a linked minecraft username", invokingUserName))
|
simpleResponse(s, i, fmt.Sprintf("`%s` does not have a linked minecraft username", invokingUserName))
|
||||||
} else {
|
} else {
|
||||||
// execute RCON
|
// execute RCON
|
||||||
response, err := conn.Execute(fmt.Sprintf("whitelist remove %s", existingMCUsername))
|
response, err := conn.Execute(fmt.Sprintf("whitelist remove %s", existingMCUsername))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
simpleResponse(s, i, fmt.Sprintf("Failed to remove %s from whitelist: %s", existingMCUsername, err.Error()))
|
simpleResponse(s, i, fmt.Sprintf("Failed to remove `%s` from whitelist: %s", existingMCUsername, err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// this can happen if the username is not a real player, OR if the user is already not on the whitelist
|
// this can happen if the username is not a real player, OR if the user is already not on the whitelist
|
||||||
if !strings.EqualFold(response, fmt.Sprintf("Removed %s from the whitelist", existingMCUsername)) {
|
if !strings.EqualFold(response, fmt.Sprintf("Removed %s from the whitelist", existingMCUsername)) {
|
||||||
simpleResponse(s, i, fmt.Sprintf("Failed to remove %s from whitelist: %s", existingMCUsername, response))
|
simpleResponse(s, i, fmt.Sprintf("Failed to remove `%s` from whitelist: %s", existingMCUsername, response))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ var (
|
|||||||
SaveDB(dbPath, db)
|
SaveDB(dbPath, db)
|
||||||
|
|
||||||
// send response
|
// send response
|
||||||
simpleResponse(s, i, fmt.Sprintf("%s unlinked minecraft username %s", invokingUserName, existingMCUsername))
|
simpleResponse(s, i, fmt.Sprintf("`%s` unlinked minecraft username `%s`", invokingUserName, existingMCUsername))
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -119,9 +119,9 @@ var (
|
|||||||
existingMCUsername, ok := db[invokingUserID]
|
existingMCUsername, ok := db[invokingUserID]
|
||||||
|
|
||||||
if ok {
|
if ok {
|
||||||
simpleResponse(s, i, fmt.Sprintf("%s is %s", invokingUserName, existingMCUsername))
|
simpleResponse(s, i, fmt.Sprintf("`%s` is `%s`", invokingUserName, existingMCUsername))
|
||||||
} else {
|
} else {
|
||||||
simpleResponse(s, i, fmt.Sprintf("%s does not have a linked minecraft username", invokingUserName))
|
simpleResponse(s, i, fmt.Sprintf("`%s` does not have a linked minecraft username", invokingUserName))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user