]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_swhois.cpp
Wrong place probably
[user/henk/code/inspircd.git] / src / modules / m_swhois.cpp
index 9ebbb2a083783fbf1a4203b1b262bde0a924c4e1..8276f610f1ae1e3a787c85534e9a138bf811de81 100644 (file)
@@ -21,29 +21,23 @@ class CommandSwhois : public Command
 {
        
  public:
-       CommandSwhois (InspIRCd* Instance) : Command(Instance,"SWHOIS",'o',2)
+       CommandSwhois (InspIRCd* Instance) : Command(Instance,"SWHOIS","o",2)
        {
                this->source = "m_swhois.so";
                syntax = "<nick> <swhois>";
                TRANSLATE3(TR_NICK, TR_TEXT, TR_END);
        }
 
-       CmdResult Handle(const char** parameters, int pcnt, User* user)
+       CmdResult Handle(const char* const* parameters, int pcnt, User* user)
        {
                User* dest = ServerInstance->FindNick(parameters[0]);
                
                if (!dest)
                {
-                       user->WriteServ("401 %s %s :No such nick/channel", user->nick, parameters[0]);
+                       user->WriteNumeric(401, "%s %s :No such nick/channel", user->nick, parameters[0]);
                        return CMD_FAILURE;
                }
 
-               if (!*parameters[1])
-               {
-                       user->WriteServ("NOTICE %s :*** SWHOIS: Whois line must be specified", user->nick);
-                       return CMD_FAILURE;
-               }
-               
                std::string line;
                for (int i = 1; i < pcnt; i++)
                {
@@ -90,7 +84,7 @@ class CommandSwhois : public Command
                delete metadata;
                
                // If it's an empty swhois, unset it (not ideal, but ok)
-               if (text.empty())
+               if (text->empty())
                {
                        dest->Shrink("swhois");
                        delete text;
@@ -139,6 +133,7 @@ class ModuleSWhois : public Module
                                ServerInstance->SendWhoisLine(user, dest, 320, "%s %s :%s",user->nick,dest->nick,swhois->c_str());
                        }
                }
+
                /* Dont block anything */
                return 0;
        }
@@ -206,17 +201,24 @@ class ModuleSWhois : public Module
                if ((target_type == TYPE_USER) && (extname == "swhois"))
                {
                        User* dest = (User*)target;
-                       // if they dont already have an swhois field, accept the remote server's
+
+                       // if they already have an swhois field, trash it and replace it with the remote one.
                        std::string* text;
-                       if (!dest->GetExt("swhois", text))
+                       if (dest->GetExt("swhois", text))
                        {
-                               std::string* text = new std::string(extdata);
-                               dest->Extend("swhois",text);
+                               user->Shrink("swhois");
+                               delete text;
                        }
+
+                       if (extdata.empty())
+                               return; // XXX does the command parser even allow sending blank mdata? it needs to here! -- w00t
+
+                       text2 = new std::string(extdata);
+                       dest->Extend("swhois", text);
                }
        }
        
-       virtual void OnPostCommand(const std::string &command, const char **params, int pcnt, User *user, CmdResult result, const std::string &original_line)
+       virtual void OnPostCommand(const std::string &command, const char* const* params, int pcnt, User *user, CmdResult result, const std::string &original_line)
        {
                if ((command != "OPER") || (result != CMD_SUCCESS))
                        return;
@@ -276,7 +278,7 @@ class ModuleSWhois : public Module
        
        virtual Version GetVersion()
        {
-               return Version(1, 1, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
+               return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
        }
 };