From be24cbdaa1173563a625636ee05a8dcaddc24800 Mon Sep 17 00:00:00 2001 From: frostycoolslug Date: Tue, 15 Mar 2005 16:13:24 +0000 Subject: Added Comment with regard to 'hidden command' :D git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@886 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_randquote.cpp | 46 ++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_randquote.cpp b/src/modules/m_randquote.cpp index d14445d51..197efcdb6 100644 --- a/src/modules/m_randquote.cpp +++ b/src/modules/m_randquote.cpp @@ -21,20 +21,38 @@ #include "channels.h" #include "modules.h" +Server *Srv; +FileReader *quotes; + +std::string q_file; +std::string prefix; +std::string suffix; + + /* $ModDesc: Provides random Quotes on Connect. */ +void handle_randquote(char** parameters, int pcntl, userrec *user) +{ + std::string str; + int fsize; + char buf[MAXBUF]; + + fsize = quotes->FileSize(); + srand(time(NULL)); + str = quotes->GetLine(rand() % fsize); + + sprintf(buf,"NOTICE %s :%s%s%s",user->nick,prefix.c_str(),str.c_str(),suffix.c_str()); + Srv->SendServ(user->fd, buf); + return; +} + class ModuleRandQuote : public Module { private: Server *Srv; ConfigReader *conf; - FileReader *quotes; - - std::string q_file; - std::string prefix; - std::string suffix; public: ModuleRandQuote() @@ -59,6 +77,8 @@ class ModuleRandQuote : public Module printf("m_randquote: QuoteFile not Found!! Please check your config.\n\n"); exit(0); } + /* Hidden Command -- Mode clients assume /quote sends raw data to an IRCd >:D */ + Srv->AddCommand("QUOTE",handle_randquote,0,0); } virtual ~ModuleRandQuote() @@ -75,17 +95,10 @@ class ModuleRandQuote : public Module virtual void OnUserConnect(userrec* user) { - std::string str; - int fsize; - char buf[MAXBUF]; - - fsize = quotes->FileSize(); - srand(time(NULL)); - str = quotes->GetLine(rand() % fsize); - - sprintf(buf,"NOTICE %s :%s%s%s",user->nick,prefix.c_str(),str.c_str(),suffix.c_str()); - Srv->SendServ(user->fd, buf); - return; + // Make a fake pointer to be passed to handle_randquote() + // Dont try this at home kiddies :D + char *rar = "RAR"; + handle_randquote(&rar, 0, user); } }; @@ -113,4 +126,3 @@ extern "C" void * init_module( void ) { return new ModuleRandQuoteFactory; } - -- cgit v1.2.3