]> jfr.im git - irc/evilnet/mod.chanfix.git/blob - REHASHCommand.cc
Fixed missing include, corebug fix was already applied here.
[irc/evilnet/mod.chanfix.git] / REHASHCommand.cc
1 /**
2 * REHASHCommand.cc
3 *
4 * 07/22/2005 - Reed Loden <reed@reedloden.com>
5 * Initial Version
6 *
7 * Reload the bot's configuration file
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
22 * USA.
23 *
24 * $Id$
25 */
26
27 #include "gnuworld_config.h"
28 #include "StringTokenizer.h"
29
30 #include "chanfix.h"
31 #include "responses.h"
32
33 RCSTAG("$Id$");
34
35 namespace gnuworld
36 {
37 namespace cf
38 {
39
40 void REHASHCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
41 {
42 StringTokenizer st(Message);
43
44 std::string option;
45 if (st.size() > 1)
46 option = string_upper(st[1]);
47
48 if (option == "CONFIG" || option.empty()) {
49 bot->readConfigFile(bot->getConfigFileName());
50
51 bot->SendTo(theClient,
52 bot->getResponse(theUser,
53 language::reloaded_conf,
54 std::string("Successfully rehashed configuration file.")).c_str());
55 bot->logDebugMessage("%s (%s) rehashed the chanfix module.",
56 theUser->getUserName().c_str(),
57 theClient->getRealNickUserHost().c_str());
58 return;
59 }
60
61 if (option == "HELP") {
62 bot->helpTable.clear();
63 bot->loadHelpTable();
64
65 bot->SendTo(theClient,
66 bot->getResponse(theUser,
67 language::reloaded_help,
68 std::string("Successfully reloaded help tables. %i entries in table.", bot->helpTable.size())).c_str());
69 bot->logDebugMessage("%s (%s) rehashed the chanfix help tables.",
70 theUser->getUserName().c_str(),
71 theClient->getRealNickUserHost().c_str());
72 return;
73 }
74
75 if (option == "TRANSLATIONS") {
76 bot->languageTable.clear();
77 bot->translationTable.clear();
78 bot->loadTranslationTable();
79
80 bot->SendTo(theClient, "Successfully reloaded translation tables. %i entries in table.",
81 bot->translationTable.size());
82 bot->logDebugMessage("%s (%s) rehashed the chanfix translation tables.",
83 theUser->getUserName().c_str(),
84 theClient->getRealNickUserHost().c_str());
85 return;
86 }
87
88 bot->logAdminMessage("%s (%s) REHASH %s",
89 theUser->getUserName().c_str(),
90 theClient->getRealNickUserHost().c_str(),
91 !option.empty() ? option.c_str() : "");
92
93 bot->logLastComMessage(theClient, Message);
94
95 return;
96 }
97
98 } // namespace cf
99
100 } // namespace gnuworld