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();
43 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);
53 class ModuleRandQuote : public Module
62 conf = new ConfigReader;
65 q_file = conf->ReadValue("randquote","file",0);
66 prefix = conf->ReadValue("randquote","prefix",0);
67 suffix = conf->ReadValue("randquote","suffix",0);
70 printf("m_randquote: Quotefile not specified.. Please check your config.\n\n");
75 quotes = new FileReader(q_file);
78 printf("m_randquote: QuoteFile not Found!! Please check your config.\n\n");
81 /* Hidden Command -- Mode clients assume /quote sends raw data to an IRCd >:D */
82 Srv->AddCommand("QUOTE",handle_randquote,0,0);
85 virtual ~ModuleRandQuote()
92 virtual Version GetVersion()
94 return Version(1,0,0,0);
97 virtual void OnUserConnect(userrec* user)
99 // Make a fake pointer to be passed to handle_randquote()
100 // Dont try this at home kiddies :D
102 handle_randquote(&rar, 0, user);
107 class ModuleRandQuoteFactory : public ModuleFactory
110 ModuleRandQuoteFactory()
114 ~ModuleRandQuoteFactory()
118 virtual Module * CreateModule()
120 return new ModuleRandQuote;
126 extern "C" void * init_module( void )
128 return new ModuleRandQuoteFactory;