mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-14 03:11:28 +00:00
[Bug Fix] Update bot naming check and add more explanation (#3491)
* Refactor my original PR Block all puncation,numbers, and _ * Add error message
This commit is contained in:
parent
4854201b2a
commit
50ce99ce3e
@ -1273,8 +1273,11 @@ bool Bot::IsValidName(std::string& name)
|
|||||||
if (!isupper(name[0]))
|
if (!isupper(name[0]))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (int i = 1; i < name.length(); ++i) {
|
for (char c : name.substr(1)) {
|
||||||
if ((!RuleB(Bots, AllowCamelCaseNames) && !islower(name[i])) && name[i] != '_') {
|
if (!RuleB(Bots, AllowCamelCaseNames) && !islower(c)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (isdigit(c) || ispunct(c)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5501,11 +5501,6 @@ void bot_subcommand_bot_create(Client *c, const Seperator *sep)
|
|||||||
std::string bot_name = sep->arg[1];
|
std::string bot_name = sep->arg[1];
|
||||||
bot_name = Strings::UcFirst(bot_name);
|
bot_name = Strings::UcFirst(bot_name);
|
||||||
|
|
||||||
if (Strings::Contains(bot_name, "_")) {
|
|
||||||
c->Message(Chat::White, "Bot name cannot contain underscores!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (arguments < 2 || !sep->IsNumber(2)) {
|
if (arguments < 2 || !sep->IsNumber(2)) {
|
||||||
c->Message(Chat::White, "Invalid class!");
|
c->Message(Chat::White, "Invalid class!");
|
||||||
return;
|
return;
|
||||||
@ -8858,8 +8853,8 @@ uint32 helper_bot_create(Client *bot_owner, std::string bot_name, uint8 bot_clas
|
|||||||
bot_owner->Message(
|
bot_owner->Message(
|
||||||
Chat::White,
|
Chat::White,
|
||||||
fmt::format(
|
fmt::format(
|
||||||
"'{}' is an invalid name. You may only use characters 'A-Z', 'a-z' and '_'.",
|
"'{}' is an invalid name. You may only use characters 'A-Z' or 'a-z'. Mixed case {} allowed.",
|
||||||
bot_name
|
bot_name, RuleB(Bots, AllowCamelCaseNames) ? "is" : "is not"
|
||||||
).c_str()
|
).c_str()
|
||||||
);
|
);
|
||||||
return bot_id;
|
return bot_id;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user