1
0
mirror of https://github.com/anope/anope.git synced 2026-06-30 11:46:39 +02:00

Allow skipping user modes in keepmodes.

This commit is contained in:
Sadie Powell
2025-01-13 15:35:13 +00:00
parent 3582bc0f58
commit 9d165f13e7
2 changed files with 15 additions and 5 deletions
+11 -1
View File
@@ -558,7 +558,17 @@ command { service = "NickServ"; name = "SASET NOEXPIRE"; command = "nickserv/sas
*
* Allows configuring services to keep user modes across logins.
*/
module { name = "ns_set_keepmodes" }
module
{
name = "ns_set_keepmodes"
/*
* Anope will try to not restore user modes that aren't settable by users. However, if
* you have modes that you don't want to be automatically restored you can list them
* here.
*/
#norestore = "ABCabc"
}
command { service = "NickServ"; name = "SET KEEPMODES"; command = "nickserv/set/keepmodes"; }
command { service = "NickServ"; name = "SASET KEEPMODES"; command = "nickserv/saset/keepmodes"; permission = "nickserv/saset/keepmodes"; }
+4 -4
View File
@@ -191,13 +191,13 @@ public:
{
if (keep_modes.HasExt(u->Account()))
{
const auto norestore = Config->GetModule(this)->Get<const Anope::string>("norestore");
User::ModeList modes = u->Account()->last_modes;
for (const auto &[last_mode, last_value] : modes)
{
UserMode *um = ModeManager::FindUserModeByName(last_mode);
/* if the null user can set the mode, then it's probably safe */
if (um && um->CanSet(NULL))
u->SetMode(NULL, last_mode, last_value);
auto *um = ModeManager::FindUserModeByName(last_mode);
if (um && um->CanSet(nullptr) && norestore.find(um->mchar) == Anope::string::npos)
u->SetMode(nullptr, last_mode, last_value);
}
}
}