diff options
| author | 2012-06-12 08:24:43 -0700 | |
|---|---|---|
| committer | 2012-06-12 08:24:43 -0700 | |
| commit | 8f9d909a052b98c288434c947aff7b55b84be201 (patch) | |
| tree | 15e66b2590aaffbdab78684a4b30324c351c8564 /src/modules | |
| parent | Fix build on Debian GNU/Hurd platforms, thanks to Jonathan Wiltshire <jmw@deb... (diff) | |
| parent | m_namesx Add support for altering /WHO replies to be compliant with the speci... (diff) | |
Merge pull request #190 from attilamolnar/insp21+namesx upstream/obsolete/insp21
[2.1] Add support to m_namesx for altering /WHO replies
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/m_namesx.cpp | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/src/modules/m_namesx.cpp b/src/modules/m_namesx.cpp index 603af0693..4d29a2754 100644 --- a/src/modules/m_namesx.cpp +++ b/src/modules/m_namesx.cpp @@ -35,7 +35,7 @@ class ModuleNamesX : public Module void init() { - Implementation eventlist[] = { I_OnPreCommand, I_OnNamesListItem, I_On005Numeric, I_OnEvent }; + Implementation eventlist[] = { I_OnPreCommand, I_OnNamesListItem, I_On005Numeric, I_OnEvent, I_OnSendWhoLine }; ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); } @@ -80,6 +80,41 @@ class ModuleNamesX : public Module prefixes = memb->chan->GetAllPrefixChars(memb->user); } + void OnSendWhoLine(User* source, const std::vector<std::string>& params, User* user, std::string& line) + { + if (!cap.ext.get(source) || line.empty()) + return; + + std::string::size_type pos = line.find(':'); + if (pos == std::string::npos || pos < 2) + return; + pos -= 2; + // Don't do anything if the user has no prefixes + if ((line[pos] == 'H') || (line[pos] == 'G') || (line[pos] == '*')) + return; + + // 352 21DAAAAAB #chan ident localhost insp21.test 21DAAAAAB H@ :0 a + // a b pos + std::string::size_type a = 4 + source->nick.length() + 1; + std::string::size_type b = line.find(' ', a); + if (b == std::string::npos) + return; + + // Try to find this channel + std::string channame = line.substr(a, b-a); + Channel* chan = ServerInstance->FindChan(channame.c_str()); + if (!chan) + return; + + // Don't do anything if the user has only one prefix + std::string prefixes = chan->GetAllPrefixChars(user); + if (prefixes.length() <= 1) + return; + + line.erase(pos, 1); + line.insert(pos, prefixes); + } + void OnEvent(Event& ev) { cap.HandleEvent(ev); |
