diff options
| author | 2020-06-08 18:14:19 +0100 | |
|---|---|---|
| committer | 2020-06-08 18:14:19 +0100 | |
| commit | 58e9055162e003f991870637b73f8ec4044d56a8 (patch) | |
| tree | 62289918baee8739fb14a71d3e10c47e1eff5210 /src/modules/m_botmode.cpp | |
| parent | Rip out compatibility code for the 2.0 protocol. (diff) | |
| parent | Add an ISUPPORT token for the bot mode and 'B' to the WHO flags. (diff) | |
Merge branch 'insp3' into master.
Diffstat (limited to 'src/modules/m_botmode.cpp')
| -rw-r--r-- | src/modules/m_botmode.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/modules/m_botmode.cpp b/src/modules/m_botmode.cpp index 18c1951f9..25dd39018 100644 --- a/src/modules/m_botmode.cpp +++ b/src/modules/m_botmode.cpp @@ -25,6 +25,8 @@ #include "inspircd.h" #include "modules/ctctags.h" +#include "modules/isupport.h" +#include "modules/who.h" #include "modules/whois.h" enum @@ -60,7 +62,11 @@ class BotTag : public ClientProtocol::MessageTagProvider } }; -class ModuleBotMode : public Module, public Whois::EventListener +class ModuleBotMode + : public Module + , public ISupport::EventListener + , public Who::EventListener + , public Whois::EventListener { private: SimpleUserModeHandler bm; @@ -69,12 +75,31 @@ class ModuleBotMode : public Module, public Whois::EventListener public: ModuleBotMode() : Module(VF_VENDOR, "Adds user mode B (bot) which marks users with it set as bots in their /WHOIS response.") + , ISupport::EventListener(this) + , Who::EventListener(this) , Whois::EventListener(this) , bm(this, "bot", 'B') , tag(this, bm) { } + void OnBuildISupport(ISupport::TokenMap& tokens) override + { + tokens["BOT"] = ConvToStr(bm.GetModeChar()); + } + + ModResult OnWhoLine(const Who::Request& request, LocalUser* source, User* user, Membership* memb, Numeric::Numeric& numeric) override + { + size_t flag_index; + if (!request.GetFieldIndex('f', flag_index)) + return MOD_RES_PASSTHRU; + + if (user->IsModeSet(bm)) + numeric.GetParams()[flag_index].push_back('B'); + + return MOD_RES_PASSTHRU; + } + void OnWhois(Whois::Context& whois) override { if (whois.GetTarget()->IsModeSet(bm)) |
