1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
25 /* $ModDesc: Provides random Quotes on Connect. */
27 class ModuleRandQuote : public Module
43 conf = new ConfigReader;
46 q_file = conf->ReadValue("randquote","file",0);
47 prefix = conf->ReadValue("randquote","prefix",0);
48 suffix = conf->ReadValue("randquote","suffix",0);
51 printf("m_randquote: Quotefile not specified.. Please check your config.\n\n");
56 quotes = new FileReader(q_file);
59 printf("m_randquote: QuoteFile not Found!! Please check your config.\n\n");
64 virtual ~ModuleRandQuote()
71 virtual Version GetVersion()
73 return Version(1,0,0,0);
76 virtual void OnUserConnect(userrec* user)
82 fsize = quotes->FileSize();
84 str = quotes->GetLine(rand() % fsize);
86 sprintf(buf,"NOTICE %s :%s%s%s",user->nick,prefix.c_str(),str.c_str(),suffix.c_str());
87 Srv->SendServ(user->fd, buf);
93 class ModuleRandQuoteFactory : public ModuleFactory
96 ModuleRandQuoteFactory()
100 ~ModuleRandQuoteFactory()
104 virtual Module * CreateModule()
106 return new ModuleRandQuote;
112 extern "C" void * init_module( void )
114 return new ModuleRandQuoteFactory;