X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_randquote.cpp;h=21cb2257dc8358ba0bfbe2b11dfeb383bd3e6703;hb=2630a87bb13b089e6d0fdcff4bcd0f3a9612e52f;hp=38c11ff959a110dcf80aee6cf8501d3b6dba0b0d;hpb=b817341e2149af163011cce47605ae17b4f67eeb;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_randquote.cpp b/src/modules/m_randquote.cpp index 38c11ff95..21cb2257d 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. @@ -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(std::vector(), user); + cmd.Handle(std::vector(), user); } };