]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/cmd_topic.cpp
Annotations
[user/henk/code/inspircd.git] / src / cmd_topic.cpp
index bd7308f2648bf561d327835385a05894570efc52..6d2f6cf9e38b303408de09f0b1b7488310c23355 100644 (file)
  * ---------------------------------------------------
  */
 
-#include "inspircd_config.h"
 #include "configreader.h"
 #include "users.h"
 #include "modules.h"
-#include "message.h"
-#include "commands.h"
 #include "commands/cmd_topic.h"
-#include "helperfuncs.h"
 
-extern InspIRCd* ServerInstance;
-extern int MODCOUNT;
-extern time_t TIME;
-extern ModuleList modules;
-extern FactoryList factory;
 
-void cmd_topic::Handle (const char** parameters, int pcnt, userrec *user)
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+       return new cmd_topic(Instance);
+}
+
+CmdResult cmd_topic::Handle (const char** parameters, int pcnt, userrec *user)
 {
        chanrec* Ptr;
 
@@ -41,7 +38,7 @@ void cmd_topic::Handle (const char** parameters, int pcnt, userrec *user)
                        if ((Ptr->modes[CM_SECRET]) && (!Ptr->HasUser(user)))
                        {
                                user->WriteServ("401 %s %s :No such nick/channel",user->nick, Ptr->name);
-                               return;
+                               return CMD_FAILURE;
                        }
                        if (Ptr->topicset)
                        {
@@ -56,8 +53,9 @@ void cmd_topic::Handle (const char** parameters, int pcnt, userrec *user)
                else
                {
                        user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[0]);
+                       return CMD_FAILURE;
                }
-               return;
+               return CMD_SUCCESS;
        }
        else if (pcnt>1)
        {
@@ -69,12 +67,12 @@ void cmd_topic::Handle (const char** parameters, int pcnt, userrec *user)
                                if (!Ptr->HasUser(user))
                                {
                                        user->WriteServ("442 %s %s :You're not on that channel!",user->nick, Ptr->name);
-                                       return;
+                                       return CMD_FAILURE;
                                }
-                               if ((Ptr->modes[CM_TOPICLOCK]) && (cstatus(user,Ptr)<STATUS_HOP))
+                               if ((Ptr->modes[CM_TOPICLOCK]) && (Ptr->GetStatus(user) < STATUS_HOP))
                                {
                                        user->WriteServ("482 %s %s :You must be at least a half-operator to change modes on this channel", user->nick, Ptr->name);
-                                       return;
+                                       return CMD_FAILURE;
                                }
                        }
                        char topic[MAXTOPIC];
@@ -85,12 +83,12 @@ void cmd_topic::Handle (const char** parameters, int pcnt, userrec *user)
                                int MOD_RESULT = 0;
                                FOREACH_RESULT(I_OnLocalTopicChange,OnLocalTopicChange(user,Ptr,topic));
                                if (MOD_RESULT)
-                                       return;
+                                       return CMD_FAILURE;
                        }
 
                        strlcpy(Ptr->topic,topic,MAXTOPIC-1);
                        strlcpy(Ptr->setby,user->nick,NICKMAX-1);
-                       Ptr->topicset = TIME;
+                       Ptr->topicset = ServerInstance->Time();
                        Ptr->WriteChannel(user, "TOPIC %s :%s", Ptr->name, Ptr->topic);
                        if (IS_LOCAL(user))
                        {
@@ -100,7 +98,9 @@ void cmd_topic::Handle (const char** parameters, int pcnt, userrec *user)
                else
                {
                        user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[0]);
+                       return CMD_FAILURE;
                }
        }
+       return CMD_SUCCESS;
 }