]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_randquote.cpp
Change allocation of commands/modes
[user/henk/code/inspircd.git] / src / modules / m_randquote.cpp
index 0353ae939bdf45fa8fd00c06f0320df673921674..21cb2257dc8358ba0bfbe2b11dfeb383bd3e6703 100644 (file)
@@ -2,8 +2,8 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
+ *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ * See: http://wiki.inspircd.org/Credits
  *
  * This program is free but copyrighted software; see
  *            the file COPYING for details.
@@ -31,7 +31,7 @@ class CommandRandquote : public Command
                this->source = "m_randquote.so";
        }
 
-       CmdResult Handle (const char* const* parameters, int pcntl, User *user)
+       CmdResult Handle (const std::vector<std::string>& parameters, User *user)
        {
                std::string str;
                int fsize;
@@ -40,11 +40,11 @@ class CommandRandquote : public Command
                {
                        fsize = quotes->FileSize();
                        str = quotes->GetLine(rand() % fsize);
-                       user->WriteServ("NOTICE %s :%s%s%s",user->nick,prefix.c_str(),str.c_str(),suffix.c_str());
+                       user->WriteServ("NOTICE %s :%s%s%s",user->nick.c_str(),prefix.c_str(),str.c_str(),suffix.c_str());
                }
                else
                {
-                       user->WriteServ("NOTICE %s :Your administrator specified an invalid quotes file, please bug them about this.", user->nick);
+                       user->WriteServ("NOTICE %s :Your administrator specified an invalid quotes file, please bug them about this.", user->nick.c_str());
                        return CMD_FAILURE;
                }
 
@@ -55,23 +55,21 @@ class CommandRandquote : public Command
 class ModuleRandQuote : public Module
 {
  private:
-       CommandRandquote* mycommand;
+       CommandRandquote cmd;
        ConfigReader *conf;
  public:
        ModuleRandQuote(InspIRCd* Me)
-               : Module(Me)
+               : Module(Me), cmd(Me)
        {
-               
+
                conf = new ConfigReader(ServerInstance);
                // Sort the Randomizer thingie..
-               srand(time(NULL));
+               srand(ServerInstance->Time());
 
                q_file = conf->ReadValue("randquote","file",0);
                prefix = conf->ReadValue("randquote","prefix",0);
                suffix = conf->ReadValue("randquote","suffix",0);
 
-               mycommand = NULL;
-
                if (q_file.empty())
                {
                        throw ModuleException("m_randquote: Quotefile not specified - Please check your config.");
@@ -85,29 +83,27 @@ class ModuleRandQuote : public Module
                else
                {
                        /* Hidden Command -- Mode clients assume /quote sends raw data to an IRCd >:D */
-                       mycommand = new CommandRandquote(ServerInstance);
-                       ServerInstance->AddCommand(mycommand);
+                       ServerInstance->AddCommand(&cmd);
                }
                Implementation eventlist[] = { I_OnUserConnect };
                ServerInstance->Modules->Attach(eventlist, this, 1);
        }
 
-       
+
        virtual ~ModuleRandQuote()
        {
                delete conf;
                delete quotes;
        }
-       
+
        virtual Version GetVersion()
        {
-               return Version(1,2,0,1,VF_VENDOR,API_VERSION);
+               return Version("$Id$",VF_VENDOR,API_VERSION);
        }
-       
+
        virtual void OnUserConnect(User* user)
        {
-               if (mycommand)
-                       mycommand->Handle(NULL, 0, user);
+               cmd.Handle(std::vector<std::string>(), user);
        }
 };