1
0
mirror of https://github.com/anope/anope.git synced 2026-07-10 05:43:13 +02:00

Add a string overload of User::SetModes.

This commit is contained in:
Sadie Powell
2024-01-08 14:14:57 +00:00
parent 5b23fae8bf
commit 0439e3b21b
5 changed files with 15 additions and 9 deletions
+1
View File
@@ -303,6 +303,7 @@ public:
* @param umodes The modes
*/
void SetModes(BotInfo *bi, const char *umodes, ...) ATTR_FORMAT(3, 4);
void SetModes(BotInfo *bi, const Anope::string &umodes);
/** Set a string of modes on a user internally
* @param setter who/what is setting the mode
+1 -1
View File
@@ -154,7 +154,7 @@ public:
source.Reply(NICK_X_NOT_IN_USE, target.c_str());
else
{
u2->SetModes(source.service, "%s", modes.c_str());
u2->SetModes(source.service, modes);
source.Reply(_("Changed usermodes of \002%s\002 to %s."), u2->nick.c_str(), modes.c_str());
u2->SendMessage(source.service, _("\002%s\002 changed your usermodes to %s."), source.GetNick().c_str(), modes.c_str());
+1 -1
View File
@@ -112,7 +112,7 @@ public:
IRCD->SendOper(user);
if (!modes.empty())
user->SetModes(OperServ, "%s", modes.c_str());
user->SetModes(OperServ, modes);
}
}
+2 -2
View File
@@ -223,7 +223,7 @@ public:
const Anope::string &modesonid = Config->GetModule(this)->Get<Anope::string>("modesonid");
if (!modesonid.empty())
u->SetModes(NickServ, "%s", modesonid.c_str());
u->SetModes(NickServ, modesonid);
}
void Collide(User *u, NickAlias *na) override
@@ -351,7 +351,7 @@ public:
const Anope::string &modesonid = block->Get<const Anope::string>("modesonid");
if (!modesonid.empty())
u->SetModes(NickServ, "%s", modesonid.c_str());
u->SetModes(NickServ, modesonid);
if (block->Get<bool>("forceemail", "yes") && u->Account()->email.empty())
{
+10 -5
View File
@@ -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)
{