diff options
| author | Sadie Powell <sadie@witchery.services> | 2025-04-14 11:31:19 +0100 |
|---|---|---|
| committer | Sadie Powell <sadie@witchery.services> | 2025-04-14 11:31:19 +0100 |
| commit | d04a312d0d1edd1223b55ed89b7fb707ceca3117 (patch) | |
| tree | 39b0c165b17d5ff4571423b2bc279b34546c3b72 /modules/chanserv | |
| parent | 099f0ce43a7e34e4a6e74d91aa911c745c262ba8 (diff) | |
Add Anope::Templace and switch all template strings to use it.
Diffstat (limited to 'modules/chanserv')
| -rw-r--r-- | modules/chanserv/cs_akick.cpp | 6 | ||||
| -rw-r--r-- | modules/chanserv/cs_ban.cpp | 13 | ||||
| -rw-r--r-- | modules/chanserv/cs_kick.cpp | 13 |
3 files changed, 22 insertions, 10 deletions
diff --git a/modules/chanserv/cs_akick.cpp b/modules/chanserv/cs_akick.cpp index 5453aa5d2..e6672b965 100644 --- a/modules/chanserv/cs_akick.cpp +++ b/modules/chanserv/cs_akick.cpp @@ -567,8 +567,10 @@ public: if (reason.empty()) { reason = Language::Translate(u, Config->GetModule(this).Get<const Anope::string>("autokickreason").c_str()); - reason = reason.replace_all_cs("%n", u->nick) - .replace_all_cs("%c", c->name); + reason = Anope::Template(reason, { + { "channel", c->name }, + { "nick", u->nick }, + }); } if (reason.empty()) reason = Language::Translate(u, _("User has been banned from the channel")); diff --git a/modules/chanserv/cs_ban.cpp b/modules/chanserv/cs_ban.cpp index 74dc129f4..8560e4eac 100644 --- a/modules/chanserv/cs_ban.cpp +++ b/modules/chanserv/cs_ban.cpp @@ -111,8 +111,7 @@ public: if (reason.length() > reasonmax) reason = reason.substr(0, reasonmax); - Anope::string signkickformat = Config->GetModule("chanserv").Get<Anope::string>("signkickformat", "%m (%n)"); - signkickformat = signkickformat.replace_all_cs("%n", source.GetNick()); + auto signkickformat = Config->GetModule("chanserv").Get<Anope::string>("signkickformat", "{message} ({nick})"); User *u = source.GetUser(); User *u2 = User::Find(target, true); @@ -160,7 +159,10 @@ public: { if (ci->HasExt("SIGNKICK") || (ci->HasExt("SIGNKICK_LEVEL") && !source.AccessFor(ci).HasPriv("SIGNKICK"))) { - signkickformat = signkickformat.replace_all_cs("%m", reason); + signkickformat = Anope::Template(signkickformat, { + { "message", reason }, + { "nick", source.GetNick() }, + }); c->Kick(ci->WhoSends(), u2, signkickformat); } else @@ -215,7 +217,10 @@ public: if (ci->HasExt("SIGNKICK") || (ci->HasExt("SIGNKICK_LEVEL") && !u_access.HasPriv("SIGNKICK"))) { reason += " (Matches " + mask + ")"; - signkickformat = signkickformat.replace_all_cs("%m", reason); + signkickformat = Anope::Template(signkickformat, { + { "message", reason }, + { "nick", source.GetNick() }, + }); c->Kick(ci->WhoSends(), uc->user, signkickformat); } else diff --git a/modules/chanserv/cs_kick.cpp b/modules/chanserv/cs_kick.cpp index 210a5168c..5ba61eaef 100644 --- a/modules/chanserv/cs_kick.cpp +++ b/modules/chanserv/cs_kick.cpp @@ -48,8 +48,7 @@ public: if (reason.length() > reasonmax) reason = reason.substr(0, reasonmax); - Anope::string signkickformat = Config->GetModule("chanserv").Get<Anope::string>("signkickformat", "%m (%n)"); - signkickformat = signkickformat.replace_all_cs("%n", source.GetNick()); + auto signkickformat = Config->GetModule("chanserv").Get<Anope::string>("signkickformat", "{message} ({nick})"); AccessGroup u_access = source.AccessFor(ci); @@ -71,7 +70,10 @@ public: if (ci->HasExt("SIGNKICK") || (ci->HasExt("SIGNKICK_LEVEL") && !u_access.HasPriv("SIGNKICK"))) { - signkickformat = signkickformat.replace_all_cs("%m", reason); + signkickformat = Anope::Template(signkickformat, { + { "message", reason }, + { "nick", source.GetNick() }, + }); c->Kick(ci->WhoSends(), u2, signkickformat); } else @@ -105,7 +107,10 @@ public: if (ci->HasExt("SIGNKICK") || (ci->HasExt("SIGNKICK_LEVEL") && !u_access.HasPriv("SIGNKICK"))) { reason += " (Matches " + mask + ")"; - signkickformat = signkickformat.replace_all_cs("%m", reason); + signkickformat = Anope::Template(signkickformat, { + { "message", reason }, + { "nick", source.GetNick() }, + }); c->Kick(ci->WhoSends(), uc->user, signkickformat); } else |
