]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_randquote.cpp
Update copyright headers.
[user/henk/code/inspircd.git] / src / modules / m_randquote.cpp
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2013, 2020 Sadie Powell <sadie@witchery.services>
5  *   Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
6  *   Copyright (C) 2010 Daniel De Graaf <danieldg@inspircd.org>
7  *   Copyright (C) 2009 Uli Schlachter <psychon@inspircd.org>
8  *   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
9  *   Copyright (C) 2003, 2006-2008, 2010 Craig Edwards <brain@inspircd.org>
10  *
11  * This file is part of InspIRCd.  InspIRCd is free software: you can
12  * redistribute it and/or modify it under the terms of the GNU General Public
13  * License as published by the Free Software Foundation, version 2.
14  *
15  * This program is distributed in the hope that it will be useful, but WITHOUT
16  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  */
23
24
25 #include "inspircd.h"
26
27 class ModuleRandQuote : public Module
28 {
29  private:
30         std::string prefix;
31         std::string suffix;
32         std::vector<std::string> quotes;
33
34  public:
35         void init() CXX11_OVERRIDE
36         {
37                 ConfigTag* conf = ServerInstance->Config->ConfValue("randquote");
38                 prefix = conf->getString("prefix");
39                 suffix = conf->getString("suffix");
40                 FileReader reader(conf->getString("file", "quotes", 1));
41                 quotes = reader.GetVector();
42         }
43
44         void OnUserConnect(LocalUser* user) CXX11_OVERRIDE
45         {
46                 if (!quotes.empty())
47                 {
48                         unsigned long random = ServerInstance->GenRandomInt(quotes.size());
49                         user->WriteNotice(prefix + quotes[random] + suffix);
50                 }
51         }
52
53         Version GetVersion() CXX11_OVERRIDE
54         {
55                 return Version("Allows random quotes to be sent to users when they connect to the server.", VF_VENDOR);
56         }
57 };
58
59 MODULE_INIT(ModuleRandQuote)