X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_randquote.cpp;h=e2910e7cd96e003dc3f3f33479dde98a629a912a;hb=de25d946733f774e3a5b53a58438a9c92af0acbe;hp=c03b2777a59154ceb6f46b27595486dc6ca450e5;hpb=1200d6285b1d64699c6fa2c8241e2ee40f52d2a3;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_randquote.cpp b/src/modules/m_randquote.cpp index c03b2777a..e2910e7cd 100644 --- a/src/modules/m_randquote.cpp +++ b/src/modules/m_randquote.cpp @@ -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& 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(), user); + cmd.Handle(std::vector(), user); } };