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 FileReader *quotes = NULL;
27 std::string q_file = "";
28 std::string prefix = "";
29 std::string suffix = "";
31 /* $ModDesc: Provides random Quotes on Connect. */
33 void handle_randquote(char** parameters, int pcntl, userrec *user)
40 fsize = quotes->FileSize();
41 str = quotes->GetLine(rand() % fsize);
42 sprintf(buf,"NOTICE %s :%s%s%s",user->nick,prefix.c_str(),str.c_str(),suffix.c_str());
43 Srv->SendServ(user->fd, buf);
51 class ModuleRandQuote : public Module
60 conf = new ConfigReader;
61 // Sort the Randomizer thingie..
64 q_file = conf->ReadValue("randquote","file",0);
65 prefix = conf->ReadValue("randquote","prefix",0);
66 suffix = conf->ReadValue("randquote","suffix",0);
69 log(DEFAULT,"m_randquote: Quotefile not specified - Please check your config.");
73 quotes = new FileReader(q_file);
76 log(DEFAULT,"m_randquote: QuoteFile not Found!! Please check your config - module will not function.");
79 /* Hidden Command -- Mode clients assume /quote sends raw data to an IRCd >:D */
80 else Srv->AddCommand("QUOTE",handle_randquote,0,0,"m_randquote.so");
83 virtual ~ModuleRandQuote()
90 virtual Version GetVersion()
92 return Version(1,0,0,1,VF_VENDOR);
95 virtual void OnUserConnect(userrec* user)
97 // Make a fake pointer to be passed to handle_randquote()
98 // Dont try this at home kiddies :D
100 handle_randquote(&rar, 0, user);
105 class ModuleRandQuoteFactory : public ModuleFactory
108 ModuleRandQuoteFactory()
112 ~ModuleRandQuoteFactory()
116 virtual Module * CreateModule()
118 return new ModuleRandQuote;
124 extern "C" void * init_module( void )
126 return new ModuleRandQuoteFactory;