[Commands] Cleanup #ban, #ipban, #flag, #kick, #setlsinfo, and #setpass Commands. (#2104)

* [Commands] Cleanup #ban, #ipban, #flag, and #kick Commands.
- Cleanup messages and logic.
- Add ServerFlagUpdate_Struct for flag updates.

* Add #setlsinfo and #setpass to cleanup.

* Update setlsinfo.cpp

* Update database.cpp

* Update database.cpp

* Update command.cpp
This commit is contained in:
Kinglykrab
2022-05-07 23:28:45 -04:00
committed by GitHub
parent 07b46ed445
commit d9c41526e8
13 changed files with 312 additions and 227 deletions
+42 -20
View File
@@ -2,28 +2,50 @@
void command_setpass(Client *c, const Seperator *sep)
{
if (sep->argnum != 2) {
c->Message(Chat::White, "Format: #setpass accountname password");
int arguments = sep->argnum;
if (arguments < 2) {
c->Message(Chat::White, "Usage: #setpass [Account Name] [Password]");
return;
}
else {
std::string user;
std::string loginserver;
ParseAccountString(sep->arg[1], user, loginserver);
int16 tmpstatus = 0;
uint32 tmpid = database.GetAccountIDByName(user.c_str(), loginserver.c_str(), &tmpstatus);
if (!tmpid) {
c->Message(Chat::White, "Error: Account not found");
}
else if (tmpstatus > c->Admin()) {
c->Message(Chat::White, "Cannot change password: Account's status is higher than yours");
}
else if (database.SetLocalPassword(tmpid, sep->arg[2])) {
c->Message(Chat::White, "Password changed.");
}
else {
c->Message(Chat::White, "Error changing password.");
}
std::string account_name;
std::string loginserver;
ParseAccountString(sep->arg[1], account_name, loginserver);
int16 status = 0;
auto account_id = database.GetAccountIDByName(account_name, loginserver, &status);
if (!account_id) {
c->Message(
Chat::White,
fmt::format(
"Account {} not found.",
account_name
).c_str()
);
return;
}
if (status > c->Admin()) {
c->Message(
Chat::White,
fmt::format(
"You cannot change the password for Account {} as its status is higher than yours.",
account_name
).c_str()
);
return;
}
c->Message(
Chat::White,
fmt::format(
"Password {} changed for Account {}.",
(
database.SetLocalPassword(account_id, sep->arg[2]) ?
"successfully" :
"failed"
),
account_name
).c_str()
);
}