]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_userip.cpp
Fix these to use new hook system (u_listmode wasnt fixed yet)
[user/henk/code/inspircd.git] / src / modules / m_userip.cpp
index 5a56fe576656065cce5c88c0582e959ea173f97a..d75bbb4291a33d9d6129dea89fe25f2ec39efbe6 100644 (file)
  * ---------------------------------------------------
  */
 
-#include <stdio.h>
-#include <string>
-#include "users.h"
-#include "channels.h"
-#include "modules.h"
 #include "inspircd.h"
 
 /* $ModDesc: Provides support for USERIP command */
 
 /** Handle /USERIP
  */
-class cmd_userip : public command_t
+class CommandUserip : public Command
 {
  public:
-       cmd_userip (InspIRCd* Instance) : command_t(Instance,"USERIP", 'o', 1)
+       CommandUserip (InspIRCd* Instance) : Command(Instance,"USERIP", 'o', 1)
        {
                this->source = "m_userip.so";
                syntax = "<nick>{,<nick>}";
        }
 
-       CmdResult Handle (const char** parameters, int pcnt, userrec *user)
+       CmdResult Handle (const char** parameters, int pcnt, User *user)
        {
                std::string retbuf = std::string("340 ") + user->nick + " :";
 
                for (int i = 0; i < pcnt; i++)
                {
-                       userrec *u = ServerInstance->FindNick(parameters[i]);
+                       User *u = ServerInstance->FindNick(parameters[i]);
                        if ((u) && (u->registered == REG_ALL))
                        {
-                               retbuf = retbuf + u->nick + (IS_OPER(u) ? "*" : "") + "=+" + u->ident + "@" + u->GetIPString();
+                               retbuf = retbuf + u->nick + (IS_OPER(u) ? "*" : "") + "=+" + u->ident + "@" + u->GetIPString() + " ";
                        }
                }
 
                user->WriteServ(retbuf);
 
                /* Dont send to the network */
-               return CMD_FAILURE;
+               return CMD_LOCALONLY;
        }
 };
 
 class ModuleUserIP : public Module
 {
-       cmd_userip* mycommand;
+       CommandUserip* mycommand;
  public:
        ModuleUserIP(InspIRCd* Me)
-               : Module::Module(Me)
+               : Module(Me)
        {
                
-               mycommand = new cmd_userip(ServerInstance);
+               mycommand = new CommandUserip(ServerInstance);
                ServerInstance->AddCommand(mycommand);
+               Implementation eventlist[] = { I_On005Numeric };
+               ServerInstance->Modules->Attach(eventlist, this, 1);
        }
 
        void Implements(char* List)
@@ -84,29 +81,5 @@ class ModuleUserIP : public Module
        
 };
 
-// stuff down here is the module-factory stuff. For basic modules you can ignore this.
-
-class ModuleUserIPFactory : public ModuleFactory
-{
- public:
-       ModuleUserIPFactory()
-       {
-       }
-       
-       ~ModuleUserIPFactory()
-       {
-       }
-       
-       virtual Module * CreateModule(InspIRCd* Me)
-       {
-               return new ModuleUserIP(Me);
-       }
-       
-};
-
-
-extern "C" void * init_module( void )
-{
-       return new ModuleUserIPFactory;
-}
+MODULE_INIT(ModuleUserIP)