diff --git a/data/nickserv.example.conf b/data/nickserv.example.conf index 9f45c9edd..9c46979a7 100644 --- a/data/nickserv.example.conf +++ b/data/nickserv.example.conf @@ -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"; } diff --git a/modules/nickserv/ns_set_keepmodes.cpp b/modules/nickserv/ns_set_keepmodes.cpp index f282d403a..34ba3f7e9 100644 --- a/modules/nickserv/ns_set_keepmodes.cpp +++ b/modules/nickserv/ns_set_keepmodes.cpp @@ -191,13 +191,13 @@ public: { if (keep_modes.HasExt(u->Account())) { + const auto norestore = Config->GetModule(this)->Get("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); } } }