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 * ---------------------------------------------------
33 /* $ModDesc: Provides random Quotes on Connect. */
35 void handle_randquote(char** parameters, int pcntl, userrec *user)
41 fsize = quotes->FileSize();
42 str = quotes->GetLine(rand() % fsize);
44 sprintf(buf,"NOTICE %s :%s%s%s",user->nick,prefix.c_str(),str.c_str(),suffix.c_str());
45 Srv->SendServ(user->fd, buf);
52 class ModuleRandQuote : public Module
61 conf = new ConfigReader;
62 // Sort the Randomizer thingie..
66 q_file = conf->ReadValue("randquote","file",0);
67 prefix = conf->ReadValue("randquote","prefix",0);
68 suffix = conf->ReadValue("randquote","suffix",0);
71 printf("m_randquote: Quotefile not specified.. Please check your config.\n\n");
76 quotes = new FileReader(q_file);
79 printf("m_randquote: QuoteFile not Found!! Please check your config.\n\n");
82 /* Hidden Command -- Mode clients assume /quote sends raw data to an IRCd >:D */
83 Srv->AddCommand("QUOTE",handle_randquote,0,0,"m_randquote.so");
86 virtual ~ModuleRandQuote()
93 virtual Version GetVersion()
95 return Version(1,0,0,0);
98 virtual void OnUserConnect(userrec* user)
100 // Make a fake pointer to be passed to handle_randquote()
101 // Dont try this at home kiddies :D
103 handle_randquote(&rar, 0, user);
108 class ModuleRandQuoteFactory : public ModuleFactory
111 ModuleRandQuoteFactory()
115 ~ModuleRandQuoteFactory()
119 virtual Module * CreateModule()
121 return new ModuleRandQuote;
127 extern "C" void * init_module( void )
129 return new ModuleRandQuoteFactory;