CmdResult Handle (const std::vector<std::string>& 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;
}
{
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));
}