X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_randquote.cpp;h=668eea0e5cc0e8a2d1ae8fa83b247b3150c23b9a;hb=ccd4c11ea1a43d079eaae9708482ef4a9148796c;hp=f353701e1efdd8c79b2a6bdb81c4cf928b91a9c1;hpb=84a1569cd60daa64b1ae52a1fff62c0dc4d78850;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_randquote.cpp b/src/modules/m_randquote.cpp index f353701e1..668eea0e5 100644 --- a/src/modules/m_randquote.cpp +++ b/src/modules/m_randquote.cpp @@ -41,12 +41,13 @@ class CommandRandquote : public Command CmdResult Handle (const std::vector& parameters, User *user) { - std::string str; - int fsize; - - fsize = quotes->FileSize(); - str = quotes->GetLine(ServerInstance->GenRandomInt(fsize)); - user->WriteServ("NOTICE %s :%s%s%s",user->nick.c_str(),prefix.c_str(),str.c_str(),suffix.c_str()); + int fsize = quotes->FileSize(); + if (fsize) + { + std::string str = quotes->GetLine(ServerInstance->GenRandomInt(fsize)); + if (!str.empty()) + user->WriteServ("NOTICE %s :%s%s%s",user->nick.c_str(),prefix.c_str(),str.c_str(),suffix.c_str()); + } return CMD_SUCCESS; } @@ -75,7 +76,7 @@ class ModuleRandQuote : public Module { throw ModuleException("m_randquote: QuoteFile not Found!! Please check your config - module will not function."); } - ServerInstance->AddCommand(&cmd); + ServerInstance->Modules->AddService(cmd); Implementation eventlist[] = { I_OnUserConnect }; ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); }