X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_randquote.cpp;h=668eea0e5cc0e8a2d1ae8fa83b247b3150c23b9a;hb=571714e28b26cc59cbc8d27098a5ba981240ee2d;hp=5fa63d8f4fad65bdca9d27b1c3734e669a1d787e;hpb=3af9c3f8950f864bcf9cdd56127cd4014827dece;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_randquote.cpp b/src/modules/m_randquote.cpp index 5fa63d8f4..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,9 +76,9 @@ 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, 1); + ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); }