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 * ---------------------------------------------------
23 #include "helperfuncs.h"
26 FileReader *quotes = NULL;
28 std::string q_file = "";
29 std::string prefix = "";
30 std::string suffix = "";
32 /* $ModDesc: Provides random Quotes on Connect. */
34 void handle_randquote(char** parameters, int pcntl, userrec *user)
41 fsize = quotes->FileSize();
42 str = quotes->GetLine(rand() % fsize);
43 sprintf(buf,"NOTICE %s :%s%s%s",user->nick,prefix.c_str(),str.c_str(),suffix.c_str());
44 Srv->SendServ(user->fd, buf);
52 class ModuleRandQuote : public Module
61 conf = new ConfigReader;
62 // Sort the Randomizer thingie..
65 q_file = conf->ReadValue("randquote","file",0);
66 prefix = conf->ReadValue("randquote","prefix",0);
67 suffix = conf->ReadValue("randquote","suffix",0);
70 log(DEFAULT,"m_randquote: Quotefile not specified - Please check your config.");
74 quotes = new FileReader(q_file);
77 log(DEFAULT,"m_randquote: QuoteFile not Found!! Please check your config - module will not function.");
80 /* Hidden Command -- Mode clients assume /quote sends raw data to an IRCd >:D */
81 else Srv->AddCommand("QUOTE",handle_randquote,0,0,"m_randquote.so");
84 virtual ~ModuleRandQuote()
91 virtual Version GetVersion()
93 return Version(1,0,0,1,VF_VENDOR);
96 virtual void OnUserConnect(userrec* user)
98 // Make a fake pointer to be passed to handle_randquote()
99 // Dont try this at home kiddies :D
101 handle_randquote(&rar, 0, user);
106 class ModuleRandQuoteFactory : public ModuleFactory
109 ModuleRandQuoteFactory()
113 ~ModuleRandQuoteFactory()
117 virtual Module * CreateModule()
119 return new ModuleRandQuote;
125 extern "C" void * init_module( void )
127 return new ModuleRandQuoteFactory;