diff options
author | Sadie Powell <sadie@witchery.services> | 2024-01-08 14:14:57 +0000 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2024-01-08 14:14:57 +0000 |
commit | 0439e3b21bb197c80974074a614fe3cdf16ddf5a (patch) | |
tree | 704fbdf05031fad7be76c757988ee581530df43e /src | |
parent | 5b23fae8bfb40ae23a4cd206b4b58cb076600609 (diff) |
Add a string overload of User::SetModes.
Diffstat (limited to 'src')
-rw-r--r-- | src/users.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/users.cpp b/src/users.cpp index f4e77c5f9..fc509ee0a 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -372,7 +372,7 @@ void User::Identify(NickAlias *na) { if (!this->nc->o->ot->modes.empty()) { - this->SetModes(NULL, "%s", this->nc->o->ot->modes.c_str()); + this->SetModes(NULL, this->nc->o->ot->modes); this->SendMessage(NULL, "Changing your usermodes to \002%s\002", this->nc->o->ot->modes.c_str()); UserMode *um = ModeManager::FindUserModeByName("OPER"); if (um && !this->HasMode("OPER") && this->nc->o->ot->modes.find(um->mchar) != Anope::string::npos) @@ -543,7 +543,7 @@ void User::SetModeInternal(const MessageSource &source, UserMode *um, const Anop { if (!this->nc->o->ot->modes.empty()) { - this->SetModes(NULL, "%s", this->nc->o->ot->modes.c_str()); + this->SetModes(NULL, this->nc->o->ot->modes); this->SendMessage(NULL, "Changing your usermodes to \002%s\002", this->nc->o->ot->modes.c_str()); UserMode *oper = ModeManager::FindUserModeByName("OPER"); if (oper && !this->HasMode("OPER") && this->nc->o->ot->modes.find(oper->mchar) != Anope::string::npos) @@ -620,13 +620,18 @@ void User::SetModes(BotInfo *bi, const char *umodes, ...) { char buf[BUFSIZE] = ""; va_list args; - Anope::string modebuf, sbuf; - int add = -1; va_start(args, umodes); vsnprintf(buf, BUFSIZE - 1, umodes, args); va_end(args); - spacesepstream sep(buf); + SetModes(bi, Anope::string(buf)); +} + +void User::SetModes(BotInfo *bi, const Anope::string &umodes) +{ + Anope::string modebuf, sbuf; + int add = -1; + spacesepstream sep(umodes); sep.GetToken(modebuf); for (auto mode : modebuf) { |