1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 static FileReader *quotes = NULL;
22 /* $ModDesc: Provides random Quotes on Connect. */
26 class CommandRandquote : public Command
29 CommandRandquote(Module* Creator) : Command(Creator,"RANDQUOTE", 0)
33 CmdResult Handle (const std::vector<std::string>& parameters, User *user)
38 if (q_file.empty() || quotes->Exists())
40 fsize = quotes->FileSize();
41 str = quotes->GetLine(rand() % fsize);
42 user->WriteServ("NOTICE %s :%s%s%s",user->nick.c_str(),prefix.c_str(),str.c_str(),suffix.c_str());
46 user->WriteServ("NOTICE %s :Your administrator specified an invalid quotes file, please bug them about this.", user->nick.c_str());
54 class ModuleRandQuote : public Module
63 // Sort the Randomizer thingie..
64 srand(ServerInstance->Time());
66 q_file = conf.ReadValue("randquote","file",0);
67 prefix = conf.ReadValue("randquote","prefix",0);
68 suffix = conf.ReadValue("randquote","suffix",0);
72 throw ModuleException("m_randquote: Quotefile not specified - Please check your config.");
75 quotes = new FileReader(q_file);
78 throw ModuleException("m_randquote: QuoteFile not Found!! Please check your config - module will not function.");
82 /* Hidden Command -- Mode clients assume /quote sends raw data to an IRCd >:D */
83 ServerInstance->AddCommand(&cmd);
85 Implementation eventlist[] = { I_OnUserConnect };
86 ServerInstance->Modules->Attach(eventlist, this, 1);
90 virtual ~ModuleRandQuote()
95 virtual Version GetVersion()
97 return Version("Provides random Quotes on Connect.",VF_VENDOR);
100 virtual void OnUserConnect(LocalUser* user)
102 cmd.Handle(std::vector<std::string>(), user);
106 MODULE_INIT(ModuleRandQuote)