]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_botmode.cpp
core_hostname_lookup: find answer record of the correct type instead of assuming...
[user/henk/code/inspircd.git] / src / modules / m_botmode.cpp
index 949332ba562b55ec34a90530d8d43ee29ab8a3ca..e0236bc17c4a8756b3a949bb537ee88b126c23df 100644 (file)
@@ -21,8 +21,6 @@
 
 #include "inspircd.h"
 
-/* $ModDesc: Provides user mode +B to mark the user as a bot */
-
 /** Handles user mode +B
  */
 class BotMode : public SimpleUserModeHandler
@@ -31,41 +29,28 @@ class BotMode : public SimpleUserModeHandler
        BotMode(Module* Creator) : SimpleUserModeHandler(Creator, "bot", 'B') { }
 };
 
-class ModuleBotMode : public Module
+class ModuleBotMode : public Module, public Whois::EventListener
 {
        BotMode bm;
  public:
        ModuleBotMode()
-               : bm(this)
+               : Whois::EventListener(this)
+               , bm(this)
        {
        }
 
-       void init()
-       {
-               if (!ServerInstance->Modes->AddMode(&bm))
-                       throw ModuleException("Could not add new modes!");
-               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(335, "is a bot on " + ServerInstance->Config->Network);
                }
        }
-
 };
 
-
 MODULE_INIT(ModuleBotMode)