]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_randquote.cpp
Get rid of a bunch of memory-wasting C-style strings
[user/henk/code/inspircd.git] / src / modules / m_randquote.cpp
index c03b2777a59154ceb6f46b27595486dc6ca450e5..e2910e7cd96e003dc3f3f33479dde98a629a912a 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.
@@ -26,9 +26,8 @@ std::string suffix;
 class CommandRandquote : public Command
 {
  public:
-       CommandRandquote (InspIRCd* Instance) : Command(Instance,"RANDQUOTE", 0, 0)
+       CommandRandquote(Module* Creator) : Command(Creator,"RANDQUOTE", 0)
        {
-               this->source = "m_randquote.so";
        }
 
        CmdResult Handle (const std::vector<std::string>& parameters, User *user)
@@ -48,36 +47,34 @@ class CommandRandquote : public Command
                        return CMD_FAILURE;
                }
 
-               return CMD_LOCALONLY;
+               return CMD_SUCCESS;
        }
 };
 
 class ModuleRandQuote : public Module
 {
  private:
-       CommandRandquote* mycommand;
+       CommandRandquote cmd;
        ConfigReader *conf;
  public:
-       ModuleRandQuote(InspIRCd* Me)
-               : Module(Me)
+       ModuleRandQuote()
+               : cmd(this)
        {
 
-               conf = new ConfigReader(ServerInstance);
+               conf = new ConfigReader;
                // 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.");
                }
 
-               quotes = new FileReader(ServerInstance, q_file);
+               quotes = new FileReader(q_file);
                if(!quotes->Exists())
                {
                        throw ModuleException("m_randquote: QuoteFile not Found!! Please check your config - module will not function.");
@@ -85,8 +82,7 @@ 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);
@@ -101,13 +97,12 @@ class ModuleRandQuote : public Module
 
        virtual Version GetVersion()
        {
-               return Version("$Id$",VF_VENDOR,API_VERSION);
+               return Version("Provides random Quotes on Connect.",VF_VENDOR,API_VERSION);
        }
 
        virtual void OnUserConnect(User* user)
        {
-               if (mycommand)
-                       mycommand->Handle(std::vector<std::string>(), user);
+               cmd.Handle(std::vector<std::string>(), user);
        }
 };