diff options
| author | 2021-01-07 13:13:58 +0000 | |
|---|---|---|
| committer | 2021-01-07 13:13:58 +0000 | |
| commit | 4f68d162cc55a8e35f9800a2ab85274876061861 (patch) | |
| tree | 8de0f196ab3447614a6481f9b356e5dc2bae5a27 /src/modules/m_classban.cpp | |
| parent | Add a function for shrinking module names. (diff) | |
| parent | Implement support for more XML and IRC colour code escapes. (diff) | |
Merge branch 'insp3' into master.
Diffstat (limited to 'src/modules/m_classban.cpp')
| -rw-r--r-- | src/modules/m_classban.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/modules/m_classban.cpp b/src/modules/m_classban.cpp index d3ff35a05..a469b5e6f 100644 --- a/src/modules/m_classban.cpp +++ b/src/modules/m_classban.cpp @@ -24,16 +24,28 @@ class ClassExtBan : public ExtBan::MatchingBase { + private: + std::string space; + std::string underscore; + public: ClassExtBan(Module* Creator) : ExtBan::MatchingBase(Creator, "class", 'n') + , space(" ") + , underscore("_") { } bool IsMatch(User* user, Channel* channel, const std::string& text) override { LocalUser* luser = IS_LOCAL(user); - return luser && InspIRCd::Match(luser->GetClass()->name, text); + if (!luser) + return false; + + // Replace spaces with underscores as they're prohibited in mode parameters. + std::string classname(luser->GetClass()->name); + stdalgo::string::replace_all(classname, space, underscore); + return InspIRCd::Match(classname, text); } }; |
