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
|
||||
valid := checkMcUsernameValid(requestedUsername)
|
||||
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
|
||||
}
|
||||
|
||||
@ -60,14 +60,14 @@ var (
|
||||
// execute RCON
|
||||
response, err := conn.Execute(fmt.Sprintf("whitelist add %s", requestedUsername))
|
||||
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
|
||||
}
|
||||
|
||||
// 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
|
||||
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
|
||||
}
|
||||
|
||||
@ -76,9 +76,9 @@ var (
|
||||
SaveDB(dbPath, db)
|
||||
|
||||
// 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 {
|
||||
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]
|
||||
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 {
|
||||
// execute RCON
|
||||
response, err := conn.Execute(fmt.Sprintf("whitelist remove %s", existingMCUsername))
|
||||
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
|
||||
}
|
||||
|
||||
// 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)) {
|
||||
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
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ var (
|
||||
SaveDB(dbPath, db)
|
||||
|
||||
// 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]
|
||||
|
||||
if ok {
|
||||
simpleResponse(s, i, fmt.Sprintf("%s is %s", invokingUserName, existingMCUsername))
|
||||
simpleResponse(s, i, fmt.Sprintf("`%s` is `%s`", invokingUserName, existingMCUsername))
|
||||
} 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