From 436e358b5dc3de0e431ba9651ecf580d8ede2b06 Mon Sep 17 00:00:00 2001 From: linuxdaemon Date: Sat, 14 Sep 2019 13:00:44 -0500 Subject: m_alias: Add option to strip colors when matching --- src/modules/m_alias.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp index a275853e9..577938e49 100644 --- a/src/modules/m_alias.cpp +++ b/src/modules/m_alias.cpp @@ -50,6 +50,9 @@ class Alias /** Format that must be matched for use */ std::string format; + + /** Strip color codes before match? */ + bool StripColor; }; class ModuleAlias : public Module @@ -94,6 +97,7 @@ class ModuleAlias : public Module a.UserCommand = tag->getBool("usercommand", true); a.OperOnly = tag->getBool("operonly"); a.format = tag->getString("format"); + a.StripColor = tag->getBool("stripcolor"); std::transform(a.AliasedCommand.begin(), a.AliasedCommand.end(), a.AliasedCommand.begin(), ::toupper); newAliases.insert(std::make_pair(a.AliasedCommand, a)); @@ -261,10 +265,14 @@ class ModuleAlias : public Module int DoAlias(User *user, Channel *c, Alias *a, const std::string& compare, const std::string& safe) { + std::string stripped(compare); + if (a->StripColor) + InspIRCd::StripColor(stripped); + /* Does it match the pattern? */ if (!a->format.empty()) { - if (!InspIRCd::Match(compare, a->format)) + if (!InspIRCd::Match(stripped, a->format)) return 0; } -- cgit v1.2.3