]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_randquote.cpp
Add m_sqlutils - Currently provides ID->chan/user lookups
[user/henk/code/inspircd.git] / src / modules / m_randquote.cpp
index bcc4e90424493fbe31b0664f29762c40ea51c2e3..12049b376fef5aa73d0e7e2c2fb951cf3bdedb85 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
+ *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
  *                       E-mail:
  *                <brain@chatspike.net>
  *               <Craig@chatspike.net>
@@ -24,8 +24,8 @@ using namespace std;
 #include "modules.h"
 #include "helperfuncs.h"
 
-Server *Srv;
-FileReader *quotes = NULL;
+static Server *Srv;
+static FileReader *quotes = NULL;
 
 std::string q_file = "";
 std::string prefix = "";
@@ -41,7 +41,7 @@ class cmd_randquote : public command_t
                this->source = "m_randquote.so";
        }
 
-       void Handle (char** parameters, int pcntl, userrec *user)
+       void Handle (const char** parameters, int pcntl, userrec *user)
        {
                std::string str;
                int fsize;
@@ -62,6 +62,18 @@ class cmd_randquote : public command_t
        }
 };
 
+class RandquoteException : public ModuleException
+{
+ private:
+       std::string err;
+ public:
+       RandquoteException(std::string message) : err(message) { }
+
+       virtual const char* GetReason()
+       {
+               return (char*)err.c_str();
+       }
+};
 
 class ModuleRandQuote : public Module
 {
@@ -85,15 +97,15 @@ class ModuleRandQuote : public Module
 
                if (q_file == "")
                {
-                       log(DEFAULT,"m_randquote: Quotefile not specified - Please check your config.");
-                       return;
-                }
+                       RandquoteException e("m_randquote: Quotefile not specified - Please check your config.");
+                       throw(e);
+               }
 
                quotes = new FileReader(q_file);
                if(!quotes->Exists())
                {
-                       log(DEFAULT,"m_randquote: QuoteFile not Found!! Please check your config - module will not function.");
-                       return;
+                       RandquoteException e("m_randquote: QuoteFile not Found!! Please check your config - module will not function.");
+                       throw(e);
                }
                else
                {
@@ -110,8 +122,8 @@ class ModuleRandQuote : public Module
        
        virtual ~ModuleRandQuote()
        {
-               delete conf;
-               delete quotes;
+               DELETE(conf);
+               DELETE(quotes);
        }
        
        virtual Version GetVersion()