diff options
Diffstat (limited to 'src/modules/m_botmode.cpp')
-rw-r--r-- | src/modules/m_botmode.cpp | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/src/modules/m_botmode.cpp b/src/modules/m_botmode.cpp index b29c58240..1931666d1 100644 --- a/src/modules/m_botmode.cpp +++ b/src/modules/m_botmode.cpp @@ -20,51 +20,36 @@ #include "inspircd.h" +#include "modules/whois.h" -/* $ModDesc: Provides user mode +B to mark the user as a bot */ - -/** Handles user mode +B - */ -class BotMode : public SimpleUserModeHandler +enum { - public: - BotMode(Module* Creator) : SimpleUserModeHandler(Creator, "bot", 'B') { } + // From UnrealIRCd. + RPL_WHOISBOT = 335 }; -class ModuleBotMode : public Module +class ModuleBotMode : public Module, public Whois::EventListener { - BotMode bm; + SimpleUserModeHandler bm; public: ModuleBotMode() - : bm(this) - { - } - - void init() + : Whois::EventListener(this) + , bm(this, "bot", 'B') { - ServerInstance->Modules->AddService(bm); - Implementation eventlist[] = { I_OnWhois }; - ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); } - virtual ~ModuleBotMode() - { - } - - virtual Version GetVersion() + Version GetVersion() CXX11_OVERRIDE { return Version("Provides user mode +B to mark the user as a bot",VF_VENDOR); } - virtual void OnWhois(User* src, User* dst) + void OnWhois(Whois::Context& whois) CXX11_OVERRIDE { - if (dst->IsModeSet('B')) + if (whois.GetTarget()->IsModeSet(bm)) { - ServerInstance->SendWhoisLine(src, dst, 335, src->nick+" "+dst->nick+" :is a bot on "+ServerInstance->Config->Network); + whois.SendLine(RPL_WHOISBOT, "is a bot on " + ServerInstance->Config->Network); } } - }; - MODULE_INIT(ModuleBotMode) |