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 #include "helperfuncs.h"
28 FileReader *quotes = NULL;
30 std::string q_file = "";
31 std::string prefix = "";
32 std::string suffix = "";
34 /* $ModDesc: Provides random Quotes on Connect. */
36 void handle_randquote(char** parameters, int pcntl, userrec *user)
43 fsize = quotes->FileSize();
44 str = quotes->GetLine(rand() % fsize);
45 sprintf(buf,"NOTICE %s :%s%s%s",user->nick,prefix.c_str(),str.c_str(),suffix.c_str());
46 Srv->SendServ(user->fd, buf);
54 class ModuleRandQuote : public Module
63 conf = new ConfigReader;
64 // Sort the Randomizer thingie..
67 q_file = conf->ReadValue("randquote","file",0);
68 prefix = conf->ReadValue("randquote","prefix",0);
69 suffix = conf->ReadValue("randquote","suffix",0);
73 log(DEFAULT,"m_randquote: Quotefile not specified - Please check your config.");
77 quotes = new FileReader(q_file);
80 log(DEFAULT,"m_randquote: QuoteFile not Found!! Please check your config - module will not function.");
83 /* Hidden Command -- Mode clients assume /quote sends raw data to an IRCd >:D */
84 else Srv->AddCommand("QUOTE",handle_randquote,0,0,"m_randquote.so");
87 virtual ~ModuleRandQuote()
94 virtual Version GetVersion()
96 return Version(1,0,0,1,VF_VENDOR);
99 virtual void OnUserConnect(userrec* user)
101 // Make a fake pointer to be passed to handle_randquote()
102 // Dont try this at home kiddies :D
103 /* Or do things a slightly nicer way, and pass NULL */
105 handle_randquote(NULL, 0, user);
110 class ModuleRandQuoteFactory : public ModuleFactory
113 ModuleRandQuoteFactory()
117 ~ModuleRandQuoteFactory()
121 virtual Module * CreateModule()
123 return new ModuleRandQuote;
129 extern "C" void * init_module( void )
131 return new ModuleRandQuoteFactory;