10 /* $ModDesc: Provides random Quotes on Connect. */
12 class ModuleRandQuote : public Module
28 conf = new ConfigReader;
31 q_file = conf->ReadValue("randquote","file",0);
32 prefix = conf->ReadValue("randquote","prefix",0);
33 suffix = conf->ReadValue("randquote","suffix",0);
36 printf("m_randquote: Quotefile not specified.. Please check your config.\n\n");
41 quotes = new FileReader(q_file);
44 printf("m_randquote: QuoteFile not Found!! Please check your config.\n\n");
49 virtual ~ModuleRandQuote()
56 virtual Version GetVersion()
58 return Version(1,0,0,0);
61 virtual void OnUserConnect(userrec* user)
67 fsize = quotes->FileSize();
69 str = quotes->GetLine(rand() % fsize);
71 sprintf(buf,"NOTICE %s :%s%s%s",user->nick,prefix.c_str(),str.c_str(),suffix.c_str());
72 Srv->SendServ(user->fd, buf);
78 class ModuleRandQuoteFactory : public ModuleFactory
81 ModuleRandQuoteFactory()
85 ~ModuleRandQuoteFactory()
89 virtual Module * CreateModule()
91 return new ModuleRandQuote;
97 extern "C" void * init_module( void )
99 return new ModuleRandQuoteFactory;