2 * LISTBLOCKEDCommand.cc
4 * 03/25/2006 - Jimmy Lipham <music0m@alltel.net>
7 * Lists all blocked chans that chanfix has stored
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.
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.
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,
27 #include "gnuworld_config.h"
31 #include "responses.h"
32 #include "StringTokenizer.h"
33 #include "sqlChannel.h"
34 #include "sqlcfUser.h"
42 void LISTBLOCKEDCommand::Exec(iClient
* theClient
, sqlcfUser
* theUser
, const std::string
& Message
)
45 /* Check if channel blocking has been disabled in the config. */
46 if (!bot
->doChanBlocking()) {
47 bot
->SendTo(theClient
,
48 bot
->getResponse(theUser
,
49 language::channel_blocking_disabled
,
50 std::string("Channel blocking is disabled.")).c_str());
55 dbHandle
* cacheCon
= bot
->getLocalDBHandle();
57 std::stringstream theQuery
;
58 theQuery
<< "SELECT channel FROM channels WHERE (flags & "
59 << sqlChannel::F_BLOCKED
61 << sqlChannel::F_BLOCKED
62 << " ORDER BY channel ASC";
64 if (!cacheCon
->Exec(theQuery
.str(),true)) {
65 elog
<< "chanfix::LISTBLOCKEDCommand> SQL Error: "
66 << cacheCon
->ErrorMessage()
71 // SQL query returned no errors
72 unsigned int numBlocks
= 0;
73 std::string strBlocks
;
74 bot
->SendTo(theClient
,
75 bot
->getResponse(theUser
,
76 language::listblocks_blocked_chans
,
77 std::string("List of all blocked channels:")).c_str());
79 for (unsigned int i
= 0 ; i
< cacheCon
->Tuples(); i
++) {
80 strBlocks
+= cacheCon
->GetValue(i
, 0);
82 if (strBlocks
.size() >= 410) {
83 bot
->SendTo(theClient
, strBlocks
.c_str());
89 /* Dispose of our connection instance */
90 //bot->theManager->removeConnection(cacheCon);
93 bot
->SendTo(theClient
, strBlocks
.c_str());
95 bot
->SendTo(theClient
,
96 bot
->getResponse(theUser
,
97 language::listblocked_total_blocked
,
98 std::string("%d channels blocked.")).c_str(),
101 bot
->logAdminMessage("%s (%s) LISTBLOCKED",
102 theUser
->getUserName().c_str(),
103 theClient
->getRealNickUserHost().c_str());
105 bot
->logLastComMessage(theClient
, Message
);
110 } // namespace gnuworld