]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_botmode.cpp
Move the <disabled> tag out of the core to a new module.
[user/henk/code/inspircd.git] / src / modules / m_botmode.cpp
index c7a51beb9e08c7e7021a4b6e5277ca97bd9046c4..1931666d1527997f9ab1394596b8485975ff73e0 100644 (file)
 
 
 #include "inspircd.h"
+#include "modules/whois.h"
 
-/* $ModDesc: Provides support for unreal-style umode +B */
-
-/** 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)
+               : Whois::EventListener(this)
+               , bm(this, "bot", 'B')
        {
-               if (!ServerInstance->Modes->AddMode(&bm))
-                       throw ModuleException("Could not add new modes!");
-               Implementation eventlist[] = { I_OnWhois };
-               ServerInstance->Modules->Attach(eventlist, this, 1);
        }
 
-
-       virtual ~ModuleBotMode()
+       Version GetVersion() CXX11_OVERRIDE
        {
+               return Version("Provides user mode +B to mark the user as a bot",VF_VENDOR);
        }
 
-       virtual Version GetVersion()
+       void OnWhois(Whois::Context& whois) CXX11_OVERRIDE
        {
-               return Version("Provides support for unreal-style umode +B",VF_VENDOR);
-       }
-
-       virtual void OnWhois(User* src, User* dst)
-       {
-               if (dst->IsModeSet('B'))
+               if (whois.GetTarget()->IsModeSet(bm))
                {
-                       ServerInstance->SendWhoisLine(src, dst, 335, std::string(src->nick)+" "+std::string(dst->nick)+" :is a bot on "+ServerInstance->Config->Network);
+                       whois.SendLine(RPL_WHOISBOT, "is a bot on " + ServerInstance->Config->Network);
                }
        }
-
 };
 
-
 MODULE_INIT(ModuleBotMode)