From 1e20877e2f529b61b205a0b1202c32962ee47938 Mon Sep 17 00:00:00 2001 From: Naram Qashat Date: Mon, 21 Jun 2010 23:14:28 -0400 Subject: The next of a few "CBX OCDing over code style" commits, focusing on src/core/bs_* and src/core/cs_*. --- src/core/bs_act.cpp | 3 +- src/core/bs_assign.cpp | 3 +- src/core/bs_badwords.cpp | 22 ++--- src/core/bs_bot.cpp | 25 ++--- src/core/bs_botlist.cpp | 15 ++- src/core/bs_help.cpp | 7 +- src/core/bs_info.cpp | 184 +++++++++++++++-------------------- src/core/bs_kick.cpp | 198 +++++++++++++++++++++++--------------- src/core/bs_say.cpp | 3 +- src/core/bs_set.cpp | 123 +++++++++++++---------- src/core/bs_unassign.cpp | 3 +- src/core/cs_access.cpp | 97 +++++-------------- src/core/cs_akick.cpp | 195 +++++++++++++++++-------------------- src/core/cs_ban.cpp | 34 +++---- src/core/cs_clear.cpp | 14 +-- src/core/cs_drop.cpp | 27 ++---- src/core/cs_forbid.cpp | 7 +- src/core/cs_getkey.cpp | 4 +- src/core/cs_help.cpp | 12 +-- src/core/cs_info.cpp | 14 +-- src/core/cs_invite.cpp | 3 +- src/core/cs_kick.cpp | 26 +++-- src/core/cs_list.cpp | 55 +++-------- src/core/cs_modes.cpp | 53 +++------- src/core/cs_register.cpp | 5 +- src/core/cs_saset.cpp | 18 +--- src/core/cs_saset_noexpire.cpp | 6 +- src/core/cs_set.cpp | 16 +-- src/core/cs_set_bantype.cpp | 8 +- src/core/cs_set_description.cpp | 6 +- src/core/cs_set_email.cpp | 6 +- src/core/cs_set_entrymsg.cpp | 6 +- src/core/cs_set_founder.cpp | 13 +-- src/core/cs_set_keeptopic.cpp | 6 +- src/core/cs_set_mlock.cpp | 60 +++++------- src/core/cs_set_opnotice.cpp | 6 +- src/core/cs_set_peace.cpp | 8 +- src/core/cs_set_persist.cpp | 20 ++-- src/core/cs_set_private.cpp | 6 +- src/core/cs_set_restricted.cpp | 5 +- src/core/cs_set_secure.cpp | 6 +- src/core/cs_set_securefounder.cpp | 6 +- src/core/cs_set_secureops.cpp | 6 +- src/core/cs_set_signkick.cpp | 6 +- src/core/cs_set_successor.cpp | 10 +- src/core/cs_set_topiclock.cpp | 6 +- src/core/cs_set_url.cpp | 6 +- src/core/cs_set_xop.cpp | 12 +-- src/core/cs_status.cpp | 3 +- src/core/cs_suspend.cpp | 5 +- src/core/cs_topic.cpp | 3 +- src/core/cs_unban.cpp | 4 +- src/core/cs_xop.cpp | 27 ++---- 53 files changed, 586 insertions(+), 836 deletions(-) (limited to 'src') diff --git a/src/core/bs_act.cpp b/src/core/bs_act.cpp index d313fd587..3cf1cb0f9 100644 --- a/src/core/bs_act.cpp +++ b/src/core/bs_act.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" diff --git a/src/core/bs_assign.cpp b/src/core/bs_assign.cpp index d5fa0bdef..b6703c04c 100644 --- a/src/core/bs_assign.cpp +++ b/src/core/bs_assign.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" diff --git a/src/core/bs_badwords.cpp b/src/core/bs_badwords.cpp index 7a9c6ebdf..d4be661bf 100644 --- a/src/core/bs_badwords.cpp +++ b/src/core/bs_badwords.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" @@ -86,16 +85,14 @@ class CommandBSBadwords : public Command CommandReturn DoList(User *u, ChannelInfo *ci, const ci::string &word) { if (!ci->GetBadWordCount()) - { notice_lang(Config.s_BotServ, u, BOT_BADWORDS_LIST_EMPTY, ci->name.c_str()); - } else if (!word.empty() && strspn(word.c_str(), "1234567890,-") == word.length()) (new BadwordsListCallback(u, ci, word.c_str()))->Process(); else { bool SentHeader = false; - - for (unsigned i = 0; i < ci->GetBadWordCount(); i++) + + for (unsigned i = 0, end = ci->GetBadWordCount(); i < end; ++i) { BadWord *bw = ci->GetBadWord(i); @@ -145,12 +142,11 @@ class CommandBSBadwords : public Command return MOD_CONT; } - for (unsigned i = 0; i < ci->GetBadWordCount(); ++i) + for (unsigned i = 0, end = ci->GetBadWordCount(); i < end; ++i) { BadWord *bw = ci->GetBadWord(i); - if (!bw->word.empty() && ((Config.BSCaseSensitive && !stricmp(bw->word.c_str(), realword.c_str())) - || (!Config.BSCaseSensitive && bw->word == realword.c_str()))) + if (!bw->word.empty() && ((Config.BSCaseSensitive && !stricmp(bw->word.c_str(), realword.c_str())) || (!Config.BSCaseSensitive && bw->word == realword.c_str()))) { notice_lang(Config.s_BotServ, u, BOT_BADWORDS_ALREADY_EXISTS, bw->word.c_str(), ci->name.c_str()); return MOD_CONT; @@ -171,10 +167,10 @@ class CommandBSBadwords : public Command (new BadwordsDelCallback(u, ci, word.c_str()))->Process(); else { - unsigned i; + unsigned i, end; BadWord *badword; - for (i = 0; i < ci->GetBadWordCount(); ++i) + for (i = 0, end = ci->GetBadWordCount(); i < end; ++i) { badword = ci->GetBadWord(i); @@ -182,12 +178,12 @@ class CommandBSBadwords : public Command break; } - if (i == ci->GetBadWordCount()) + if (i == end) { notice_lang(Config.s_BotServ, u, BOT_BADWORDS_NOT_FOUND, word.c_str(), ci->name.c_str()); return MOD_CONT; } - + ci->EraseBadWord(i); notice_lang(Config.s_BotServ, u, BOT_BADWORDS_DELETED, badword->word.c_str(), ci->name.c_str()); diff --git a/src/core/bs_bot.cpp b/src/core/bs_bot.cpp index 1d3103e29..2b7cc5cf4 100644 --- a/src/core/bs_bot.cpp +++ b/src/core/bs_bot.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" @@ -57,14 +56,12 @@ class CommandBSBot : public Command return MOD_CONT; } - for (ch = nick; *ch && (ch - nick) < Config.NickLen; ch++) - { + for (ch = nick; *ch && ch - nick < Config.NickLen; ++ch) if (!isvalidnick(*ch)) { notice_lang(Config.s_BotServ, u, BOT_BAD_NICK); return MOD_CONT; } - } /* check for hardcored ircd forbidden nicks */ if (!ircdproto->IsNickValid(nick)) @@ -80,15 +77,12 @@ class CommandBSBot : public Command return MOD_CONT; } - for (ch = user; *ch && (ch - user) < Config.UserLen; ch++) - { + for (ch = user; *ch && ch - user < Config.UserLen; ++ch) if (!isalnum(*ch)) { notice_lang(Config.s_BotServ, u, BOT_BAD_IDENT, Config.UserLen); return MOD_CONT; } - } - /* We check whether the nick is registered, and inform the user * if so. You need to drop the nick manually before you can use @@ -185,14 +179,12 @@ class CommandBSBot : public Command return MOD_CONT; } - for (ch = nick; *ch && (ch - nick) < Config.NickLen; ch++) - { + for (ch = nick; *ch && ch - nick < Config.NickLen; ++ch) if (!isvalidnick(*ch)) { notice_lang(Config.s_BotServ, u, BOT_BAD_NICK); return MOD_CONT; } - } /* check for hardcored ircd forbidden nicks */ if (!ircdproto->IsNickValid(nick)) @@ -208,16 +200,12 @@ class CommandBSBot : public Command } if (user) - { - for (ch = user; *ch && (ch - user) < Config.UserLen; ch++) - { + for (ch = user; *ch && ch - user < Config.UserLen; ++ch) if (!isalnum(*ch)) { notice_lang(Config.s_BotServ, u, BOT_BAD_IDENT, Config.UserLen); return MOD_CONT; } - } - } ci::string ci_bi_nick(bi->nick.c_str()); if (ci_bi_nick != nick && findbot(nick)) @@ -271,10 +259,9 @@ class CommandBSBot : public Command if (user) { - if (ircd->ts6) { + if (ircd->ts6) // This isn't the nicest way to do this, unfortunately. bi->uid = ts6_uid_retrieve(); - } ircdproto->SendClientIntroduction(bi->nick, bi->user, bi->host, bi->real, ircd->pseudoclient_mode, bi->uid); XLine x(bi->nick.c_str(), "Reserved for services"); ircdproto->SendSQLine(&x); diff --git a/src/core/bs_botlist.cpp b/src/core/bs_botlist.cpp index ebebf7a71..bfc0cfc58 100644 --- a/src/core/bs_botlist.cpp +++ b/src/core/bs_botlist.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" @@ -31,15 +30,15 @@ class CommandBSBotList : public Command return MOD_CONT; } - for (botinfo_map::const_iterator it = BotListByNick.begin(); it != BotListByNick.end(); ++it) + for (botinfo_map::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it) { BotInfo *bi = it->second; - + if (!bi->HasFlag(BI_PRIVATE)) { if (!count) notice_lang(Config.s_BotServ, u, BOT_BOTLIST_HEADER); - count++; + ++count; u->SendMessage(Config.s_BotServ, " %-15s (%s@%s)", bi->nick.c_str(), bi->user.c_str(), bi->host.c_str()); } } @@ -48,14 +47,14 @@ class CommandBSBotList : public Command { notice_lang(Config.s_BotServ, u, BOT_BOTLIST_PRIVATE_HEADER); - for (botinfo_map::const_iterator it = BotListByNick.begin(); it != BotListByNick.end(); ++it) + for (botinfo_map::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it) { BotInfo *bi = it->second; - + if (bi->HasFlag(BI_PRIVATE)) { u->SendMessage(Config.s_BotServ, " %-15s (%s@%s)", bi->nick.c_str(), bi->user.c_str(), bi->host.c_str()); - count++; + ++count; } } } diff --git a/src/core/bs_help.cpp b/src/core/bs_help.cpp index 80070c138..3842b8910 100644 --- a/src/core/bs_help.cpp +++ b/src/core/bs_help.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" @@ -33,7 +32,7 @@ class CommandBSHelp : public Command { // Abuse syntax error to display general list help. notice_help(Config.s_BotServ, u, BOT_HELP); - for (CommandMap::const_iterator it = BotServ->Commands.begin(); it != BotServ->Commands.end(); ++it) + for (CommandMap::const_iterator it = BotServ->Commands.begin(), it_end = BotServ->Commands.end(); it != it_end; ++it) it->second->OnServHelp(u); notice_help(Config.s_BotServ, u, BOT_HELP_FOOTER, Config.BSMinUsers); } @@ -51,6 +50,4 @@ class BSHelp : public Module } }; - - MODULE_INIT(BSHelp) diff --git a/src/core/bs_info.cpp b/src/core/bs_info.cpp index 4e8cf042f..45e650d29 100644 --- a/src/core/bs_info.cpp +++ b/src/core/bs_info.cpp @@ -24,7 +24,7 @@ class CommandBSInfo : public Command *buf = 0; end = buf; - for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(); it != RegisteredChannelList.end(); ++it) + for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it) { ChannelInfo *ci = it->second; @@ -90,142 +90,114 @@ class CommandBSInfo : public Command else notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_BOT_NONE); - if (ci->botflags.HasFlag(BS_KICK_BADWORDS)) { + if (ci->botflags.HasFlag(BS_KICK_BADWORDS)) + { if (ci->ttb[TTB_BADWORDS]) - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS_BAN, - getstring(u, BOT_INFO_ACTIVE), - ci->ttb[TTB_BADWORDS]); + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS_BAN, getstring(u, BOT_INFO_ACTIVE), ci->ttb[TTB_BADWORDS]); else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS, - getstring(u, BOT_INFO_ACTIVE)); - } else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS, - getstring(u, BOT_INFO_INACTIVE)); - if (ci->botflags.HasFlag(BS_KICK_BOLDS)) { + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS, getstring(u, BOT_INFO_ACTIVE)); + } + else + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS, getstring(u, BOT_INFO_INACTIVE)); + if (ci->botflags.HasFlag(BS_KICK_BOLDS)) + { if (ci->ttb[TTB_BOLDS]) - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS_BAN, - getstring(u, BOT_INFO_ACTIVE), - ci->ttb[TTB_BOLDS]); + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS_BAN, getstring(u, BOT_INFO_ACTIVE), ci->ttb[TTB_BOLDS]); else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS, - getstring(u, BOT_INFO_ACTIVE)); - } else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS, - getstring(u, BOT_INFO_INACTIVE)); - if (ci->botflags.HasFlag(BS_KICK_CAPS)) { + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS, getstring(u, BOT_INFO_ACTIVE)); + } + else + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS, getstring(u, BOT_INFO_INACTIVE)); + if (ci->botflags.HasFlag(BS_KICK_CAPS)) + { if (ci->ttb[TTB_CAPS]) - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_BAN, - getstring(u, BOT_INFO_ACTIVE), - ci->ttb[TTB_CAPS], ci->capsmin, - ci->capspercent); + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_BAN, getstring(u, BOT_INFO_ACTIVE), ci->ttb[TTB_CAPS], ci->capsmin, ci->capspercent); else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_ON, - getstring(u, BOT_INFO_ACTIVE), ci->capsmin, - ci->capspercent); - } else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_OFF, - getstring(u, BOT_INFO_INACTIVE)); - if (ci->botflags.HasFlag(BS_KICK_COLORS)) { + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_ON, getstring(u, BOT_INFO_ACTIVE), ci->capsmin, ci->capspercent); + } + else + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_OFF, getstring(u, BOT_INFO_INACTIVE)); + if (ci->botflags.HasFlag(BS_KICK_COLORS)) + { if (ci->ttb[TTB_COLORS]) - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS_BAN, - getstring(u, BOT_INFO_ACTIVE), - ci->ttb[TTB_COLORS]); + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS_BAN, getstring(u, BOT_INFO_ACTIVE), ci->ttb[TTB_COLORS]); else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS, - getstring(u, BOT_INFO_ACTIVE)); - } else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS, - getstring(u, BOT_INFO_INACTIVE)); - if (ci->botflags.HasFlag(BS_KICK_FLOOD)) { + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS, getstring(u, BOT_INFO_ACTIVE)); + } + else + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS, getstring(u, BOT_INFO_INACTIVE)); + if (ci->botflags.HasFlag(BS_KICK_FLOOD)) + { if (ci->ttb[TTB_FLOOD]) - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_BAN, - getstring(u, BOT_INFO_ACTIVE), - ci->ttb[TTB_FLOOD], ci->floodlines, - ci->floodsecs); + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_BAN, getstring(u, BOT_INFO_ACTIVE), ci->ttb[TTB_FLOOD], ci->floodlines, ci->floodsecs); else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_ON, - getstring(u, BOT_INFO_ACTIVE), - ci->floodlines, ci->floodsecs); - } else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_OFF, - getstring(u, BOT_INFO_INACTIVE)); - if (ci->botflags.HasFlag(BS_KICK_REPEAT)) { + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_ON, getstring(u, BOT_INFO_ACTIVE), ci->floodlines, ci->floodsecs); + } + else + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_OFF, getstring(u, BOT_INFO_INACTIVE)); + if (ci->botflags.HasFlag(BS_KICK_REPEAT)) + { if (ci->ttb[TTB_REPEAT]) - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_BAN, - getstring(u, BOT_INFO_ACTIVE), - ci->ttb[TTB_REPEAT], ci->repeattimes); + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_BAN, getstring(u, BOT_INFO_ACTIVE), ci->ttb[TTB_REPEAT], ci->repeattimes); else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_ON, - getstring(u, BOT_INFO_ACTIVE), - ci->repeattimes); - } else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_OFF, - getstring(u, BOT_INFO_INACTIVE)); - if (ci->botflags.HasFlag(BS_KICK_REVERSES)) { + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_ON, getstring(u, BOT_INFO_ACTIVE), ci->repeattimes); + } + else + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_OFF, getstring(u, BOT_INFO_INACTIVE)); + if (ci->botflags.HasFlag(BS_KICK_REVERSES)) + { if (ci->ttb[TTB_REVERSES]) - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES_BAN, - getstring(u, BOT_INFO_ACTIVE), - ci->ttb[TTB_REVERSES]); + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES_BAN, getstring(u, BOT_INFO_ACTIVE), ci->ttb[TTB_REVERSES]); else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES, - getstring(u, BOT_INFO_ACTIVE)); - } else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES, - getstring(u, BOT_INFO_INACTIVE)); - if (ci->botflags.HasFlag(BS_KICK_UNDERLINES)) { + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES, getstring(u, BOT_INFO_ACTIVE)); + } + else + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES, getstring(u, BOT_INFO_INACTIVE)); + if (ci->botflags.HasFlag(BS_KICK_UNDERLINES)) + { if (ci->ttb[TTB_UNDERLINES]) - notice_lang(Config.s_BotServ, u, - BOT_INFO_CHAN_KICK_UNDERLINES_BAN, - getstring(u, BOT_INFO_ACTIVE), - ci->ttb[TTB_UNDERLINES]); + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_UNDERLINES_BAN, getstring(u, BOT_INFO_ACTIVE), ci->ttb[TTB_UNDERLINES]); else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_UNDERLINES, - getstring(u, BOT_INFO_ACTIVE)); - } else - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_UNDERLINES, - getstring(u, BOT_INFO_INACTIVE)); + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_UNDERLINES, getstring(u, BOT_INFO_ACTIVE)); + } + else + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_KICK_UNDERLINES, getstring(u, BOT_INFO_INACTIVE)); end = buf; *end = 0; - if (ci->botflags.HasFlag(BS_DONTKICKOPS)) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s", - getstring(u, BOT_INFO_OPT_DONTKICKOPS)); + if (ci->botflags.HasFlag(BS_DONTKICKOPS)) + { + end += snprintf(end, sizeof(buf) - (end - buf), "%s", getstring(u, BOT_INFO_OPT_DONTKICKOPS)); need_comma = 1; } - if (ci->botflags.HasFlag(BS_DONTKICKVOICES)) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u, BOT_INFO_OPT_DONTKICKVOICES)); + if (ci->botflags.HasFlag(BS_DONTKICKVOICES)) + { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", need_comma ? commastr : "", getstring(u, BOT_INFO_OPT_DONTKICKVOICES)); need_comma = 1; } - if (ci->botflags.HasFlag(BS_FANTASY)) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u, BOT_INFO_OPT_FANTASY)); + if (ci->botflags.HasFlag(BS_FANTASY)) + { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", need_comma ? commastr : "", getstring(u, BOT_INFO_OPT_FANTASY)); need_comma = 1; } - if (ci->botflags.HasFlag(BS_GREET)) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u, BOT_INFO_OPT_GREET)); + if (ci->botflags.HasFlag(BS_GREET)) + { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", need_comma ? commastr : "", getstring(u, BOT_INFO_OPT_GREET)); need_comma = 1; } - if (ci->botflags.HasFlag(BS_NOBOT)) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u, BOT_INFO_OPT_NOBOT)); + if (ci->botflags.HasFlag(BS_NOBOT)) + { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", need_comma ? commastr : "", getstring(u, BOT_INFO_OPT_NOBOT)); need_comma = 1; } - if (ci->botflags.HasFlag(BS_SYMBIOSIS)) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u, BOT_INFO_OPT_SYMBIOSIS)); + if (ci->botflags.HasFlag(BS_SYMBIOSIS)) + { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", need_comma ? commastr : "", getstring(u, BOT_INFO_OPT_SYMBIOSIS)); need_comma = 1; } - notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_OPTIONS, - *buf ? buf : getstring(u, BOT_INFO_OPT_NONE)); - - } else + notice_lang(Config.s_BotServ, u, BOT_INFO_CHAN_OPTIONS, *buf ? buf : getstring(u, BOT_INFO_OPT_NONE)); + } + else notice_lang(Config.s_BotServ, u, BOT_INFO_NOT_FOUND, query); return MOD_CONT; } diff --git a/src/core/bs_kick.cpp b/src/core/bs_kick.cpp index 6c8e020e4..54781a134 100644 --- a/src/core/bs_kick.cpp +++ b/src/core/bs_kick.cpp @@ -40,14 +40,18 @@ class CommandBSKick : public Command notice_lang(Config.s_BotServ, u, ACCESS_DENIED); else if (!ci->bi) notice_help(Config.s_BotServ, u, BOT_NOT_ASSIGNED); - else { - if (option == "BADWORDS") { - if (value == "ON") { - if (ttb) { + else + { + if (option == "BADWORDS") + { + if (value == "ON") + { + if (ttb) + { errno = 0; ci->ttb[TTB_BADWORDS] = strtol(ttb, NULL, 10); /* Only error if errno returns ERANGE or EINVAL or we are less then 0 - TSL */ - if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_BADWORDS] < 0) + if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_BADWORDS] < 0) { /* leaving the debug behind since we might want to know what these are */ Alog(LOG_DEBUG) << "errno is " << errno << " ERANGE " << ERANGE << " EINVAL " << EINVAL << " ttb " << ci->ttb[TTB_BADWORDS]; @@ -56,59 +60,71 @@ class CommandBSKick : public Command notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb); return MOD_CONT; } - } else { - ci->ttb[TTB_BADWORDS] = 0; } + else + ci->ttb[TTB_BADWORDS] = 0; ci->botflags.SetFlag(BS_KICK_BADWORDS); if (ci->ttb[TTB_BADWORDS]) - notice_lang(Config.s_BotServ, u, BOT_KICK_BADWORDS_ON_BAN, - ci->ttb[TTB_BADWORDS]); + notice_lang(Config.s_BotServ, u, BOT_KICK_BADWORDS_ON_BAN, ci->ttb[TTB_BADWORDS]); else notice_lang(Config.s_BotServ, u, BOT_KICK_BADWORDS_ON); - } else { + } + else + { ci->botflags.UnsetFlag(BS_KICK_BADWORDS); notice_lang(Config.s_BotServ, u, BOT_KICK_BADWORDS_OFF); } - } else if (option == "BOLDS") { - if (value == "ON") { - if (ttb) { + } + else if (option == "BOLDS") + { + if (value == "ON") + { + if (ttb) + { errno = 0; ci->ttb[TTB_BOLDS] = strtol(ttb, NULL, 10); - if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_BOLDS] < 0) + if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_BOLDS] < 0) { Alog(LOG_DEBUG) << "errno is " << errno << " ERANGE " << ERANGE << " EINVAL " << EINVAL << " ttb " << ci->ttb[TTB_BOLDS]; ci->ttb[TTB_BOLDS] = 0; notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb); return MOD_CONT; } - } else + } + else ci->ttb[TTB_BOLDS] = 0; ci->botflags.SetFlag(BS_KICK_BOLDS); if (ci->ttb[TTB_BOLDS]) - notice_lang(Config.s_BotServ, u, BOT_KICK_BOLDS_ON_BAN, - ci->ttb[TTB_BOLDS]); + notice_lang(Config.s_BotServ, u, BOT_KICK_BOLDS_ON_BAN, ci->ttb[TTB_BOLDS]); else notice_lang(Config.s_BotServ, u, BOT_KICK_BOLDS_ON); - } else { + } + else + { ci->botflags.UnsetFlag(BS_KICK_BOLDS); notice_lang(Config.s_BotServ, u, BOT_KICK_BOLDS_OFF); } - } else if (option == "CAPS") { - if (value == "ON") { + } + else if (option == "CAPS") + { + if (value == "ON") + { const char *min = params.size() > 4 ? params[4].c_str() : NULL; const char *percent = params.size() > 5 ? params[5].c_str() : NULL; - if (ttb) { + if (ttb) + { errno = 0; ci->ttb[TTB_CAPS] = strtol(ttb, NULL, 10); - if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_CAPS] < 0) + if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_CAPS] < 0) { Alog(LOG_DEBUG) << "errno is " << errno << " ERANGE " << ERANGE << " EINVAL " << EINVAL << " ttb " << ci->ttb[TTB_CAPS]; ci->ttb[TTB_CAPS] = 0; notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb); return MOD_CONT; } - } else + } + else ci->ttb[TTB_CAPS] = 0; if (!min) @@ -127,19 +143,22 @@ class CommandBSKick : public Command ci->botflags.SetFlag(BS_KICK_CAPS); if (ci->ttb[TTB_CAPS]) - notice_lang(Config.s_BotServ, u, BOT_KICK_CAPS_ON_BAN, - ci->capsmin, ci->capspercent, - ci->ttb[TTB_CAPS]); + notice_lang(Config.s_BotServ, u, BOT_KICK_CAPS_ON_BAN, ci->capsmin, ci->capspercent, ci->ttb[TTB_CAPS]); else - notice_lang(Config.s_BotServ, u, BOT_KICK_CAPS_ON, - ci->capsmin, ci->capspercent); - } else { + notice_lang(Config.s_BotServ, u, BOT_KICK_CAPS_ON, ci->capsmin, ci->capspercent); + } + else + { ci->botflags.UnsetFlag(BS_KICK_CAPS); notice_lang(Config.s_BotServ, u, BOT_KICK_CAPS_OFF); } - } else if (option == "COLORS") { - if (value == "ON") { - if (ttb) { + } + else if (option == "COLORS") + { + if (value == "ON") + { + if (ttb) + { errno = 0; ci->ttb[TTB_COLORS] = strtol(ttb, NULL, 10); if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_COLORS] < 0) @@ -149,33 +168,41 @@ class CommandBSKick : public Command notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb); return MOD_CONT; } - } else + } + else ci->ttb[TTB_COLORS] = 0; ci->botflags.SetFlag(BS_KICK_COLORS); if (ci->ttb[TTB_COLORS]) - notice_lang(Config.s_BotServ, u, BOT_KICK_COLORS_ON_BAN, - ci->ttb[TTB_COLORS]); + notice_lang(Config.s_BotServ, u, BOT_KICK_COLORS_ON_BAN, ci->ttb[TTB_COLORS]); else notice_lang(Config.s_BotServ, u, BOT_KICK_COLORS_ON); - } else { + } + else + { ci->botflags.UnsetFlag(BS_KICK_COLORS); notice_lang(Config.s_BotServ, u, BOT_KICK_COLORS_OFF); } - } else if (option == "FLOOD") { - if (value == "ON") { + } + else if (option == "FLOOD") + { + if (value == "ON") + { const char *lines = params.size() > 4 ? params[4].c_str() : NULL; const char *secs = params.size() > 5 ? params[5].c_str() : NULL; - if (ttb) { + if (ttb) + { errno = 0; ci->ttb[TTB_FLOOD] = strtol(ttb, NULL, 10); - if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_FLOOD] < 0) { + if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_FLOOD] < 0) + { Alog(LOG_DEBUG) << "errno is " << errno << " ERANGE " << ERANGE << " EINVAL " << EINVAL << " ttb " << ci->ttb[TTB_FLOOD]; ci->ttb[TTB_FLOOD] = 0; notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb); return MOD_CONT; } - } else + } + else ci->ttb[TTB_FLOOD] = 0; if (!lines) @@ -194,31 +221,35 @@ class CommandBSKick : public Command ci->botflags.SetFlag(BS_KICK_FLOOD); if (ci->ttb[TTB_FLOOD]) - notice_lang(Config.s_BotServ, u, BOT_KICK_FLOOD_ON_BAN, - ci->floodlines, ci->floodsecs, - ci->ttb[TTB_FLOOD]); + notice_lang(Config.s_BotServ, u, BOT_KICK_FLOOD_ON_BAN, ci->floodlines, ci->floodsecs, ci->ttb[TTB_FLOOD]); else - notice_lang(Config.s_BotServ, u, BOT_KICK_FLOOD_ON, - ci->floodlines, ci->floodsecs); - } else { + notice_lang(Config.s_BotServ, u, BOT_KICK_FLOOD_ON, ci->floodlines, ci->floodsecs); + } + else + { ci->botflags.UnsetFlag(BS_KICK_FLOOD); notice_lang(Config.s_BotServ, u, BOT_KICK_FLOOD_OFF); } - } else if (option == "REPEAT") { - if (value == "ON") { + } + else if (option == "REPEAT") + { + if (value == "ON") + { const char *times = params.size() > 4 ? params[4].c_str() : NULL; - if (ttb) { + if (ttb) + { errno = 0; ci->ttb[TTB_REPEAT] = strtol(ttb, NULL, 10); - if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_REPEAT] < 0) + if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_REPEAT] < 0) { Alog(LOG_DEBUG) << "errno is " << errno << " ERANGE " << ERANGE << " EINVAL " << EINVAL << " ttb " << ci->ttb[TTB_REPEAT]; ci->ttb[TTB_REPEAT] = 0; notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb); return MOD_CONT; } - } else + } + else ci->ttb[TTB_REPEAT] = 0; if (!times) @@ -230,66 +261,77 @@ class CommandBSKick : public Command ci->botflags.SetFlag(BS_KICK_REPEAT); if (ci->ttb[TTB_REPEAT]) - notice_lang(Config.s_BotServ, u, BOT_KICK_REPEAT_ON_BAN, - ci->repeattimes, ci->ttb[TTB_REPEAT]); + notice_lang(Config.s_BotServ, u, BOT_KICK_REPEAT_ON_BAN, ci->repeattimes, ci->ttb[TTB_REPEAT]); else - notice_lang(Config.s_BotServ, u, BOT_KICK_REPEAT_ON, - ci->repeattimes); - } else { + notice_lang(Config.s_BotServ, u, BOT_KICK_REPEAT_ON, ci->repeattimes); + } + else + { ci->botflags.UnsetFlag(BS_KICK_REPEAT); notice_lang(Config.s_BotServ, u, BOT_KICK_REPEAT_OFF); } - } else if (option == "REVERSES") { - if (value == "ON") { - if (ttb) { + } + else if (option == "REVERSES") + { + if (value == "ON") + { + if (ttb) + { errno = 0; - ci->ttb[TTB_REVERSES] = - strtol(ttb, NULL, 10); - if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_REVERSES] < 0) + ci->ttb[TTB_REVERSES] = strtol(ttb, NULL, 10); + if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_REVERSES] < 0) { Alog(LOG_DEBUG) << "errno is " << errno << " ERANGE " << ERANGE << " EINVAL " << EINVAL << " ttb " << ci->ttb[TTB_REVERSES]; ci->ttb[TTB_REVERSES] = 0; notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb); return MOD_CONT; } - } else + } + else ci->ttb[TTB_REVERSES] = 0; ci->botflags.SetFlag(BS_KICK_REVERSES); if (ci->ttb[TTB_REVERSES]) - notice_lang(Config.s_BotServ, u, BOT_KICK_REVERSES_ON_BAN, - ci->ttb[TTB_REVERSES]); + notice_lang(Config.s_BotServ, u, BOT_KICK_REVERSES_ON_BAN, ci->ttb[TTB_REVERSES]); else notice_lang(Config.s_BotServ, u, BOT_KICK_REVERSES_ON); - } else { + } + else + { ci->botflags.UnsetFlag(BS_KICK_REVERSES); notice_lang(Config.s_BotServ, u, BOT_KICK_REVERSES_OFF); } - } else if (option == "UNDERLINES") { - if (value == "ON") { - if (ttb) { + } + else if (option == "UNDERLINES") + { + if (value == "ON") + { + if (ttb) + { errno = 0; - ci->ttb[TTB_UNDERLINES] = - strtol(ttb, NULL, 10); - if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_UNDERLINES] < 0) + ci->ttb[TTB_UNDERLINES] = strtol(ttb, NULL, 10); + if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_UNDERLINES] < 0) { Alog(LOG_DEBUG) << "errno is " << errno << " ERANGE " << ERANGE << " EINVAL " << EINVAL << " ttb " << ci->ttb[TTB_UNDERLINES]; ci->ttb[TTB_UNDERLINES] = 0; notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb); return MOD_CONT; } - } else + } + else ci->ttb[TTB_UNDERLINES] = 0; ci->botflags.SetFlag(BS_KICK_UNDERLINES); if (ci->ttb[TTB_UNDERLINES]) - notice_lang(Config.s_BotServ, u, BOT_KICK_UNDERLINES_ON_BAN, - ci->ttb[TTB_UNDERLINES]); + notice_lang(Config.s_BotServ, u, BOT_KICK_UNDERLINES_ON_BAN, ci->ttb[TTB_UNDERLINES]); else notice_lang(Config.s_BotServ, u, BOT_KICK_UNDERLINES_ON); - } else { + } + else + { ci->botflags.UnsetFlag(BS_KICK_UNDERLINES); notice_lang(Config.s_BotServ, u, BOT_KICK_UNDERLINES_OFF); } - } else + } + else notice_help(Config.s_BotServ, u, BOT_KICK_UNKNOWN, option.c_str()); } return MOD_CONT; diff --git a/src/core/bs_say.cpp b/src/core/bs_say.cpp index a388a1ec9..40d48fef2 100644 --- a/src/core/bs_say.cpp +++ b/src/core/bs_say.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" diff --git a/src/core/bs_set.cpp b/src/core/bs_set.cpp index a5fee9d4f..9d89c696c 100644 --- a/src/core/bs_set.cpp +++ b/src/core/bs_set.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" @@ -56,90 +55,109 @@ class CommandBSSet : public Command notice_lang(Config.s_BotServ, u, BOT_SET_PRIVATE_OFF, bi->nick.c_str()); } else - { syntax_error(Config.s_BotServ, u, "SET PRIVATE", BOT_SET_PRIVATE_SYNTAX); - } return MOD_CONT; - } else if (!(ci = cs_findchan(chan))) + } + else if (!(ci = cs_findchan(chan))) notice_lang(Config.s_BotServ, u, CHAN_X_NOT_REGISTERED, chan); else if (!u->Account()->HasPriv("botserv/administration") && !check_access(u, ci, CA_SET)) notice_lang(Config.s_BotServ, u, ACCESS_DENIED); - else { - if (option == "DONTKICKOPS") { - if (value == "ON") { + else + { + if (option == "DONTKICKOPS") + { + if (value == "ON") + { ci->botflags.SetFlag(BS_DONTKICKOPS); - notice_lang(Config.s_BotServ, u, BOT_SET_DONTKICKOPS_ON, - ci->name.c_str()); - } else if (value == "OFF") { + notice_lang(Config.s_BotServ, u, BOT_SET_DONTKICKOPS_ON, ci->name.c_str()); + } + else if (value == "OFF") + { ci->botflags.UnsetFlag(BS_DONTKICKOPS); - notice_lang(Config.s_BotServ, u, BOT_SET_DONTKICKOPS_OFF, - ci->name.c_str()); - } else { - syntax_error(Config.s_BotServ, u, "SET DONTKICKOPS", - BOT_SET_DONTKICKOPS_SYNTAX); + notice_lang(Config.s_BotServ, u, BOT_SET_DONTKICKOPS_OFF, ci->name.c_str()); } - } else if (option == "DONTKICKVOICES") { - if (value == "ON") { + else + syntax_error(Config.s_BotServ, u, "SET DONTKICKOPS", BOT_SET_DONTKICKOPS_SYNTAX); + } + else if (option == "DONTKICKVOICES") + { + if (value == "ON") + { ci->botflags.SetFlag(BS_DONTKICKVOICES); - notice_lang(Config.s_BotServ, u, BOT_SET_DONTKICKVOICES_ON, - ci->name.c_str()); - } else if (value == "OFF") { + notice_lang(Config.s_BotServ, u, BOT_SET_DONTKICKVOICES_ON, ci->name.c_str()); + } + else if (value == "OFF") + { ci->botflags.UnsetFlag(BS_DONTKICKVOICES); - notice_lang(Config.s_BotServ, u, BOT_SET_DONTKICKVOICES_OFF, - ci->name.c_str()); - } else { - syntax_error(Config.s_BotServ, u, "SET DONTKICKVOICES", - BOT_SET_DONTKICKVOICES_SYNTAX); + notice_lang(Config.s_BotServ, u, BOT_SET_DONTKICKVOICES_OFF, ci->name.c_str()); } - } else if (option == "FANTASY") { - if (value == "ON") { + else + syntax_error(Config.s_BotServ, u, "SET DONTKICKVOICES", BOT_SET_DONTKICKVOICES_SYNTAX); + } + else if (option == "FANTASY") + { + if (value == "ON") + { ci->botflags.SetFlag(BS_FANTASY); notice_lang(Config.s_BotServ, u, BOT_SET_FANTASY_ON, ci->name.c_str()); - } else if (value == "OFF") { + } + else if (value == "OFF") + { ci->botflags.UnsetFlag(BS_FANTASY); notice_lang(Config.s_BotServ, u, BOT_SET_FANTASY_OFF, ci->name.c_str()); - } else { - syntax_error(Config.s_BotServ, u, "SET FANTASY", - BOT_SET_FANTASY_SYNTAX); } - } else if (option == "GREET") { - if (value == "ON") { + else + syntax_error(Config.s_BotServ, u, "SET FANTASY", BOT_SET_FANTASY_SYNTAX); + } + else if (option == "GREET") + { + if (value == "ON") + { ci->botflags.SetFlag(BS_GREET); notice_lang(Config.s_BotServ, u, BOT_SET_GREET_ON, ci->name.c_str()); - } else if (value == "OFF") { + } + else if (value == "OFF") + { ci->botflags.UnsetFlag(BS_GREET); notice_lang(Config.s_BotServ, u, BOT_SET_GREET_OFF, ci->name.c_str()); - } else { - syntax_error(Config.s_BotServ, u, "SET GREET", - BOT_SET_GREET_SYNTAX); } - } else if (u->Account()->HasCommand("botserv/set/nobot") && option == "NOBOT") { - if (value == "ON") { + else + syntax_error(Config.s_BotServ, u, "SET GREET", BOT_SET_GREET_SYNTAX); + } + else if (u->Account()->HasCommand("botserv/set/nobot") && option == "NOBOT") + { + if (value == "ON") + { ci->botflags.SetFlag(BS_NOBOT); if (ci->bi) ci->bi->UnAssign(u, ci); notice_lang(Config.s_BotServ, u, BOT_SET_NOBOT_ON, ci->name.c_str()); - } else if (value == "OFF") { + } + else if (value == "OFF") + { ci->botflags.UnsetFlag(BS_NOBOT); notice_lang(Config.s_BotServ, u, BOT_SET_NOBOT_OFF, ci->name.c_str()); - } else { - syntax_error(Config.s_BotServ, u, "SET NOBOT", - BOT_SET_NOBOT_SYNTAX); } - } else if (option == "SYMBIOSIS") { - if (value == "ON") { + else + syntax_error(Config.s_BotServ, u, "SET NOBOT", BOT_SET_NOBOT_SYNTAX); + } + else if (option == "SYMBIOSIS") + { + if (value == "ON") + { ci->botflags.SetFlag(BS_SYMBIOSIS); notice_lang(Config.s_BotServ, u, BOT_SET_SYMBIOSIS_ON, ci->name.c_str()); - } else if (value == "OFF") { + } + else if (value == "OFF") + { ci->botflags.UnsetFlag(BS_SYMBIOSIS); notice_lang(Config.s_BotServ, u, BOT_SET_SYMBIOSIS_OFF, ci->name.c_str()); - } else { - syntax_error(Config.s_BotServ, u, "SET SYMBIOSIS", - BOT_SET_SYMBIOSIS_SYNTAX); } - } else { - notice_help(Config.s_BotServ, u, BOT_SET_UNKNOWN, option.c_str()); + else + syntax_error(Config.s_BotServ, u, "SET SYMBIOSIS", BOT_SET_SYMBIOSIS_SYNTAX); } + else + notice_help(Config.s_BotServ, u, BOT_SET_UNKNOWN, option.c_str()); } return MOD_CONT; } @@ -182,6 +200,7 @@ class CommandBSSet : public Command notice_lang(Config.s_BotServ, u, BOT_HELP_CMD_SET); } }; + class BSSet : public Module { public: diff --git a/src/core/bs_unassign.cpp b/src/core/bs_unassign.cpp index 72e62a310..cab7e817c 100644 --- a/src/core/bs_unassign.cpp +++ b/src/core/bs_unassign.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" diff --git a/src/core/cs_access.cpp b/src/core/cs_access.cpp index 49d253d12..3ab17a31a 100644 --- a/src/core/cs_access.cpp +++ b/src/core/cs_access.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" @@ -153,7 +152,7 @@ class AccessDelCallback : public NumberList Nicks += ", " + std::string(access->nc->display); else Nicks = access->nc->display; - + FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, u, access->nc)); ci->EraseAccess(Number - 1); @@ -231,8 +230,7 @@ class CommandCSAccess : public Command FOREACH_MOD(I_OnAccessAdd, OnAccessAdd(ci, u, nc, level)); - Alog() << Config.s_ChanServ << ": " << u->GetMask() << " (level " << ulev << ") set access level " << level << " to " << na->nick << " (group " << nc->display << ") on channel " << -ci->name; + Alog() << Config.s_ChanServ << ": " << u->GetMask() << " (level " << ulev << ") set access level " << level << " to " << na->nick << " (group " << nc->display << ") on channel " << ci->name; notice_lang(Config.s_ChanServ, u, CHAN_ACCESS_ADDED, nc->display, ci->name.c_str(), level); return MOD_CONT; @@ -257,9 +255,9 @@ ci->name; NickCore *nc = na->nc; - unsigned i; + unsigned i, end; ChanAccess *access = NULL; - for (i = 0; i < ci->GetAccessCount(); ++i) + for (i = 0, end = ci->GetAccessCount(); i < end; ++i) { access = ci->GetAccess(i); @@ -267,14 +265,10 @@ ci->name; break; } - if (i == ci->GetAccessCount()) - { + if (i == end) notice_lang(Config.s_ChanServ, u, CHAN_ACCESS_NOT_FOUND, nick.c_str(), ci->name.c_str()); - } else if (get_access(u, ci) <= access->level && !u->Account()->HasPriv("chanserv/access/modify")) - { notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); - } else { notice_lang(Config.s_ChanServ, u, CHAN_ACCESS_DELETED, access->nc->display, ci->name.c_str()); @@ -300,7 +294,7 @@ ci->name; { bool SentHeader = false; - for (unsigned i = 0; i < ci->GetAccessCount(); i++) + for (unsigned i = 0, end = ci->GetAccessCount(); i < end; ++i) { ChanAccess *access = ci->GetAccess(i); @@ -337,7 +331,7 @@ ci->name; { bool SentHeader = false; - for (unsigned i = 0; i < ci->GetAccessCount(); ++i) + for (unsigned i = 0, end = ci->GetAccessCount(); i < end; ++i) { ChanAccess *access = ci->GetAccess(i); @@ -365,9 +359,7 @@ ci->name; CommandReturn DoClear(User *u, ChannelInfo *ci, const std::vector ¶ms) { if (!IsFounder(u, ci) && !u->Account()->HasPriv("chanserv/access/modify")) - { notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); - } else { ci->ClearAccess(); @@ -410,40 +402,22 @@ ci->name; else notice_lang(Config.s_ChanServ, u, CHAN_ACCESS_XOP, Config.s_ChanServ); } - else if (( - (is_list && !check_access(u, ci, CA_ACCESS_LIST) && !u->Account()->HasCommand("chanserv/access/list")) - || - (!is_list && !check_access(u, ci, CA_ACCESS_CHANGE) && !u->Account()->HasPriv("chanserv/access/modify")) - )) + else if ((is_list && !check_access(u, ci, CA_ACCESS_LIST) && !u->Account()->HasCommand("chanserv/access/list")) || (!is_list && !check_access(u, ci, CA_ACCESS_CHANGE) && !u->Account()->HasPriv("chanserv/access/modify"))) notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); else if (readonly && (cmd == "ADD" || cmd == "DEL" || cmd == "CLEAR")) - { notice_lang(Config.s_ChanServ, u, CHAN_ACCESS_DISABLED); - } else if (cmd == "ADD") - { this->DoAdd(u, ci, params); - } else if (cmd == "DEL") - { this->DoDel(u, ci, params); - } else if (cmd == "LIST") - { this->DoList(u, ci, params); - } else if (cmd == "VIEW") - { this->DoView(u, ci, params); - } else if (cmd == "CLEAR") - { this->DoClear(u, ci, params); - } else - { this->OnSyntaxError(u, ""); - } return MOD_CONT; } @@ -461,7 +435,6 @@ ci->name; } }; - class CommandCSLevels : public Command { CommandReturn DoSet(User *u, ChannelInfo *ci, const std::vector ¶ms) @@ -478,17 +451,12 @@ class CommandCSLevels : public Command *error = '\0'; } - if (*error != '\0') - { + if (*error) this->OnSyntaxError(u, "SET"); - } else if (level <= ACCESS_INVALID || level > ACCESS_FOUNDER) - { notice_lang(Config.s_ChanServ, u, CHAN_LEVELS_RANGE, ACCESS_INVALID + 1, ACCESS_FOUNDER - 1); - } else - { - for (int i = 0; levelinfo[i].what >= 0; i++) + for (int i = 0; levelinfo[i].what >= 0; ++i) { if (levelinfo[i].name == what) { @@ -502,8 +470,6 @@ class CommandCSLevels : public Command return MOD_CONT; } } - } - notice_lang(Config.s_ChanServ, u, CHAN_LEVELS_UNKNOWN, what.c_str(), Config.s_ChanServ); @@ -516,20 +482,18 @@ class CommandCSLevels : public Command /* Don't allow disabling of the founder level. It would be hard to change it back if you dont have access to use this command */ if (what != "FOUNDER") - { - for (int i = 0; levelinfo[i].what >= 0; i++) + for (int i = 0; levelinfo[i].what >= 0; ++i) { if (levelinfo[i].name == what) { ci->levels[levelinfo[i].what] = ACCESS_INVALID; FOREACH_MOD(I_OnLevelChange, OnLevelChange(u, ci, i, levelinfo[i].what)); - + Alog() << Config.s_ChanServ << ": " << u->GetMask() << " disabled level " << levelinfo[i].name << " on channel " << ci->name; notice_lang(Config.s_ChanServ, u, CHAN_LEVELS_DISABLED, levelinfo[i].name, ci->name.c_str()); return MOD_CONT; } } - } notice_lang(Config.s_ChanServ, u, CHAN_LEVELS_UNKNOWN, what.c_str(), Config.s_ChanServ); @@ -541,31 +505,30 @@ class CommandCSLevels : public Command notice_lang(Config.s_ChanServ, u, CHAN_LEVELS_LIST_HEADER, ci->name.c_str()); if (!levelinfo_maxwidth) - { - for (int i = 0; levelinfo[i].what >= 0; i++) { + for (int i = 0; levelinfo[i].what >= 0; ++i) + { int len = strlen(levelinfo[i].name); if (len > levelinfo_maxwidth) levelinfo_maxwidth = len; } - } - for (int i = 0; levelinfo[i].what >= 0; i++) { + for (int i = 0; levelinfo[i].what >= 0; ++i) + { int j = ci->levels[levelinfo[i].what]; - if (j == ACCESS_INVALID) { + if (j == ACCESS_INVALID) + { j = levelinfo[i].what; - if (j == CA_AUTOOP || j == CA_AUTODEOP || j == CA_AUTOVOICE - || j == CA_NOJOIN) { + if (j == CA_AUTOOP || j == CA_AUTODEOP || j == CA_AUTOVOICE || j == CA_NOJOIN) notice_lang(Config.s_ChanServ, u, CHAN_LEVELS_LIST_DISABLED, levelinfo_maxwidth, levelinfo[i].name); - } else { + else notice_lang(Config.s_ChanServ, u, CHAN_LEVELS_LIST_DISABLED, levelinfo_maxwidth, levelinfo[i].name); - } - } else if (j == ACCESS_FOUNDER) { + } + else if (j == ACCESS_FOUNDER) notice_lang(Config.s_ChanServ, u, CHAN_LEVELS_LIST_FOUNDER, levelinfo_maxwidth, levelinfo[i].name); - } else { + else notice_lang(Config.s_ChanServ, u, CHAN_LEVELS_LIST_NORMAL, levelinfo_maxwidth, levelinfo[i].name, j); - } } return MOD_CONT; @@ -604,25 +567,15 @@ class CommandCSLevels : public Command else if (!check_access(u, ci, CA_FOUNDER) && !u->Account()->HasPriv("chanserv/access/modify")) notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); else if (cmd == "SET") - { this->DoSet(u, ci, params); - } else if (cmd == "DIS" || cmd == "DISABLE") - { this->DoDisable(u, ci, params); - } else if (cmd == "LIST") - { this->DoList(u, ci, params); - } else if (cmd == "RESET") - { this->DoReset(u, ci, params); - } else - { this->OnSyntaxError(u, ""); - } return MOD_CONT; } @@ -645,7 +598,6 @@ class CommandCSLevels : public Command } }; - class CSAccess : public Module { public: @@ -660,5 +612,4 @@ class CSAccess : public Module } }; - MODULE_INIT(CSAccess) diff --git a/src/core/cs_akick.cpp b/src/core/cs_akick.cpp index e2ad9de99..cb9ae7f08 100644 --- a/src/core/cs_akick.cpp +++ b/src/core/cs_akick.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" @@ -19,8 +18,7 @@ * missing parts. */ -static void split_usermask(const char *mask, const char **nick, const char **user, - const char **host) +static void split_usermask(const char *mask, const char **nick, const char **user, const char **host) { char *mask2 = sstrdup(mask); @@ -28,7 +26,8 @@ static void split_usermask(const char *mask, const char **nick, const char **use *user = strtok(NULL, "@"); *host = strtok(NULL, ""); /* Handle special case: mask == user@host */ - if (*nick && !*user && strchr(*nick, '@')) { + if (*nick && !*user && strchr(*nick, '@')) + { *nick = NULL; *user = strtok(mask2, "@"); *host = strtok(NULL, ""); @@ -78,9 +77,7 @@ class AkickListCallback : public NumberList static void DoList(User *u, ChannelInfo *ci, unsigned index, AutoKick *akick) { - notice_lang(Config.s_ChanServ, u, CHAN_AKICK_LIST_FORMAT, index + 1, - ((akick->HasFlag(AK_ISNICK)) ? akick->nc->display : akick->mask.c_str()), - (!akick->reason.empty() ? akick->reason.c_str() : getstring(u, NO_REASON))); + notice_lang(Config.s_ChanServ, u, CHAN_AKICK_LIST_FORMAT, index + 1, akick->HasFlag(AK_ISNICK) ? akick->nc->display : akick->mask.c_str(), !akick->reason.empty() ? akick->reason.c_str() : getstring(u, NO_REASON)); } }; @@ -120,10 +117,7 @@ class AkickViewCallback : public AkickListCallback else snprintf(timebuf, sizeof(timebuf), "%s", getstring(u, UNKNOWN)); - notice_lang(Config.s_ChanServ, u, (akick->HasFlag(AK_STUCK) ? CHAN_AKICK_VIEW_FORMAT_STUCK : CHAN_AKICK_VIEW_FORMAT), index + 1, - ((akick->HasFlag(AK_ISNICK)) ? akick->nc->display : akick->mask.c_str()), - !akick->creator.empty() ? akick->creator.c_str() : getstring(u, UNKNOWN), timebuf, - (!akick->reason.empty() ? akick->reason.c_str() : getstring(u, NO_REASON))); + notice_lang(Config.s_ChanServ, u, (akick->HasFlag(AK_STUCK) ? CHAN_AKICK_VIEW_FORMAT_STUCK : CHAN_AKICK_VIEW_FORMAT), index + 1, (akick->HasFlag(AK_ISNICK)) ? akick->nc->display : akick->mask.c_str(), !akick->creator.empty() ? akick->creator.c_str() : getstring(u, UNKNOWN), timebuf, !akick->reason.empty() ? akick->reason.c_str() : getstring(u, NO_REASON)); if (akick->last_used) { @@ -197,53 +191,47 @@ class CommandCSAKick : public Command } /* Check excepts BEFORE we get this far */ - if (ModeManager::FindChannelModeByName(CMODE_EXCEPT)) + if (ModeManager::FindChannelModeByName(CMODE_EXCEPT) && is_excepted_mask(ci, mask.c_str())) { - if (is_excepted_mask(ci, mask.c_str())) - { - notice_lang(Config.s_ChanServ, u, CHAN_EXCEPTED, mask.c_str(), ci->name.c_str()); - return; - } + notice_lang(Config.s_ChanServ, u, CHAN_EXCEPTED, mask.c_str(), ci->name.c_str()); + return; } /* Check whether target nick has equal/higher access * or whether the mask matches a user with higher/equal access - Viper */ - if ((ci->HasFlag(CI_PEACE)) && nc) + if (ci->HasFlag(CI_PEACE) && nc) { - if ((nc == ci->founder) || (get_access_level(ci, nc) >= get_access(u, ci))) - { + if (nc == ci->founder || get_access_level(ci, nc) >= get_access(u, ci)) + { notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); return; - } + } } - else if ((ci->HasFlag(CI_PEACE))) + else if (ci->HasFlag(CI_PEACE)) { - /* Match against all currently online users with equal or - * higher access. - Viper */ - for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) - { - User *u2 = it->second; - - if (check_access(u2, ci, CA_FOUNDER) || (get_access(u2, ci) >= get_access(u, ci))) + /* Match against all currently online users with equal or + * higher access. - Viper */ + for (user_map::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it) + { + User *u2 = it->second; + + if ((check_access(u2, ci, CA_FOUNDER) || get_access(u2, ci) >= get_access(u, ci)) && match_usermask(mask.c_str(), u2)) { - if (match_usermask(mask.c_str(), u2)) - { - notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); - return; - } + notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); + return; } - } + } /* Match against the lastusermask of all nickalias's with equal * or higher access. - Viper */ - for (nickalias_map::const_iterator it = NickAliasList.begin(); it != NickAliasList.end(); ++it) + for (nickalias_map::const_iterator it = NickAliasList.begin(), it_end = NickAliasList.end(); it != it_end; ++it) { NickAlias *na2 = it->second; - + if (na2->HasFlag(NS_FORBIDDEN)) continue; - if (na2->nc && ((na2->nc == ci->founder) || (get_access_level(ci, na2->nc) >= get_access(u, ci)))) + if (na2->nc && (na2->nc == ci->founder || get_access_level(ci, na2->nc) >= get_access(u, ci))) { char buf[BUFSIZE]; @@ -257,12 +245,12 @@ class CommandCSAKick : public Command } } - for (unsigned j = 0; j < ci->GetAkickCount(); ++j) + for (unsigned j = 0, end = ci->GetAkickCount(); j < end; ++j) { akick = ci->GetAkick(j); - if ((akick->HasFlag(AK_ISNICK)) ? akick->nc == nc : akick->mask == mask) + if (akick->HasFlag(AK_ISNICK) ? akick->nc == nc : akick->mask == mask) { - notice_lang(Config.s_ChanServ, u, CHAN_AKICK_ALREADY_EXISTS, (akick->HasFlag(AK_ISNICK)) ? akick->nc->display : akick->mask.c_str(), ci->name.c_str()); + notice_lang(Config.s_ChanServ, u, CHAN_AKICK_ALREADY_EXISTS, akick->HasFlag(AK_ISNICK) ? akick->nc->display : akick->mask.c_str(), ci->name.c_str()); return; } } @@ -291,39 +279,39 @@ class CommandCSAKick : public Command NickAlias *na; NickCore *nc; ci::string mask = params[2]; - unsigned i; + unsigned i, end; AutoKick *akick; if (!ci->GetAkickCount()) { - notice_lang(Config.s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, ci->name.c_str()); - return; + notice_lang(Config.s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, ci->name.c_str()); + return; } na = findnick(mask); - nc = (na ? na->nc : NULL); + nc = na ? na->nc : NULL; - for (i = 0; i < ci->GetAkickCount(); ++i) + for (i = 0, end = ci->GetAkickCount(); i < end; ++i) { akick = ci->GetAkick(i); - if (akick->HasFlag(AK_ISNICK)) - continue; + if (akick->HasFlag(AK_ISNICK)) + continue; if (akick->mask == mask) - break; + break; } - if (i == ci->GetAkickCount()) + if (i == end) { - notice_lang(Config.s_ChanServ, u, CHAN_AKICK_NOT_FOUND, mask.c_str(), ci->name.c_str()); - return; + notice_lang(Config.s_ChanServ, u, CHAN_AKICK_NOT_FOUND, mask.c_str(), ci->name.c_str()); + return; } akick->SetFlag(AK_STUCK); notice_lang(Config.s_ChanServ, u, CHAN_AKICK_STUCK, akick->mask.c_str(), ci->name.c_str()); if (ci->c) - stick_mask(ci, akick); + stick_mask(ci, akick); } void DoUnStick(User *u, ChannelInfo *ci, const std::vector ¶ms) @@ -331,32 +319,32 @@ class CommandCSAKick : public Command NickAlias *na; NickCore *nc; AutoKick *akick; - unsigned i; + unsigned i, end; ci::string mask = params[2]; if (!ci->GetAkickCount()) { - notice_lang(Config.s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, ci->name.c_str()); - return; + notice_lang(Config.s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, ci->name.c_str()); + return; } na = findnick(mask); - nc = (na ? na->nc : NULL); + nc = na ? na->nc : NULL; - for (i = 0; i < ci->GetAkickCount(); ++i) + for (i = 0, end = ci->GetAkickCount(); i < end; ++i) { akick = ci->GetAkick(i); - if (akick->HasFlag(AK_ISNICK)) - continue; + if (akick->HasFlag(AK_ISNICK)) + continue; if (akick->mask == mask) - break; + break; } - if (i == ci->GetAkickCount()) + if (i == end) { - notice_lang(Config.s_ChanServ, u, CHAN_AKICK_NOT_FOUND, mask.c_str(), ci->name.c_str()); - return; + notice_lang(Config.s_ChanServ, u, CHAN_AKICK_NOT_FOUND, mask.c_str(), ci->name.c_str()); + return; } akick->UnsetFlag(AK_STUCK); @@ -367,12 +355,12 @@ class CommandCSAKick : public Command { ci::string mask = params[2]; AutoKick *akick; - unsigned i; + unsigned i, end; if (!ci->GetAkickCount()) { - notice_lang(Config.s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, ci->name.c_str()); - return; + notice_lang(Config.s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, ci->name.c_str()); + return; } /* Special case: is it a number/list? Only do search if it isn't. */ @@ -380,16 +368,14 @@ class CommandCSAKick : public Command (new AkickDelCallback(u, ci, mask.c_str()))->Process(); else { - NickAlias *na = findnick(mask); - NickCore *nc = (na ? na->nc : NULL); + NickAlias *na = findnick(mask); + NickCore *nc = (na ? na->nc : NULL); - for (i = 0; i < ci->GetAkickCount(); ++i) + for (i = 0, end = ci->GetAkickCount(); i < end; ++i) { akick = ci->GetAkick(i); - if (((akick->HasFlag(AK_ISNICK)) && akick->nc == nc) - || (!(akick->HasFlag(AK_ISNICK)) - && akick->mask == mask)) + if ((akick->HasFlag(AK_ISNICK) && akick->nc == nc) || (!akick->HasFlag(AK_ISNICK) && akick->mask == mask)) break; } @@ -411,8 +397,8 @@ class CommandCSAKick : public Command if (!ci->GetAkickCount()) { - notice_lang(Config.s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, ci->name.c_str()); - return; + notice_lang(Config.s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, ci->name.c_str()); + return; } if (!mask.empty() && isdigit(*mask.c_str()) && strspn(mask.c_str(), "1234567890,-") == mask.length()) @@ -421,18 +407,18 @@ class CommandCSAKick : public Command { bool SentHeader = false; - for (unsigned i = 0; i < ci->GetAkickCount(); ++i) + for (unsigned i = 0, end = ci->GetAkickCount(); i < end; ++i) { AutoKick *akick = ci->GetAkick(i); - if (!mask.empty()) + if (!mask.empty()) { - if (!(akick->HasFlag(AK_ISNICK)) && !Anope::Match(akick->mask.c_str(), mask.c_str(), false)) - continue; - if ((akick->HasFlag(AK_ISNICK)) && !Anope::Match(akick->nc->display, mask.c_str(), false)) - continue; - } - + if (!akick->HasFlag(AK_ISNICK) && !Anope::Match(akick->mask.c_str(), mask.c_str(), false)) + continue; + if (akick->HasFlag(AK_ISNICK) && !Anope::Match(akick->nc->display, mask.c_str(), false)) + continue; + } + if (!SentHeader) { SentHeader = true; @@ -440,10 +426,10 @@ class CommandCSAKick : public Command } AkickListCallback::DoList(u, ci, i, akick); - } - - if (!SentHeader) - notice_lang(Config.s_ChanServ, u, CHAN_AKICK_NO_MATCH, ci->name.c_str()); + } + + if (!SentHeader) + notice_lang(Config.s_ChanServ, u, CHAN_AKICK_NO_MATCH, ci->name.c_str()); } } @@ -453,8 +439,8 @@ class CommandCSAKick : public Command if (!ci->GetAkickCount()) { - notice_lang(Config.s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, ci->name.c_str()); - return; + notice_lang(Config.s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, ci->name.c_str()); + return; } if (!mask.empty() && isdigit(*mask.c_str()) && strspn(mask.c_str(), "1234567890,-") == mask.length()) @@ -463,17 +449,17 @@ class CommandCSAKick : public Command { bool SentHeader = false; - for (unsigned i = 0; i < ci->GetAkickCount(); ++i) + for (unsigned i = 0, end = ci->GetAkickCount(); i < end; ++i) { AutoKick *akick = ci->GetAkick(i); - if (!mask.empty()) + if (!mask.empty()) { - if (!(akick->HasFlag(AK_ISNICK)) && !Anope::Match(akick->mask.c_str(), mask.c_str(), false)) - continue; - if ((akick->HasFlag(AK_ISNICK)) && !Anope::Match(akick->nc->display, mask.c_str(), false)) - continue; - } + if (!akick->HasFlag(AK_ISNICK) && !Anope::Match(akick->mask.c_str(), mask.c_str(), false)) + continue; + if (akick->HasFlag(AK_ISNICK) && !Anope::Match(akick->nc->display, mask.c_str(), false)) + continue; + } if (!SentHeader) { @@ -482,7 +468,7 @@ class CommandCSAKick : public Command } AkickViewCallback::DoList(u, ci, i, akick); - } + } if (!SentHeader) notice_lang(Config.s_ChanServ, u, CHAN_AKICK_NO_MATCH, ci->name.c_str()); @@ -496,18 +482,16 @@ class CommandCSAKick : public Command if (!c) { - notice_lang(Config.s_ChanServ, u, CHAN_X_NOT_IN_USE, ci->name.c_str()); - return; + notice_lang(Config.s_ChanServ, u, CHAN_X_NOT_IN_USE, ci->name.c_str()); + return; } - for (CUserList::iterator it = c->users.begin(); it != c->users.end();) + for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ) { UserContainer *uc = *it++; if (ci->CheckKick(uc->user)) - { - count++; - } + ++count; } notice_lang(Config.s_ChanServ, u, CHAN_AKICK_ENFORCE_DONE, ci->name.c_str(), count); @@ -577,9 +561,6 @@ class CommandCSAKick : public Command } }; - - - class CSAKick : public Module { public: diff --git a/src/core/cs_ban.cpp b/src/core/cs_ban.cpp index 9aee9d1dc..578ca9868 100644 --- a/src/core/cs_ban.cpp +++ b/src/core/cs_ban.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" @@ -28,9 +27,7 @@ class CommandCSBan : public Command const char *reason = NULL; if (params.size() > 2) - { reason = params[2].c_str(); - } Channel *c = findchan(chan); ChannelInfo *ci; @@ -41,30 +38,29 @@ class CommandCSBan : public Command if (!reason) reason = "Requested"; - is_same = (stricmp(target, u->nick.c_str()) == 0); + is_same = !stricmp(target, u->nick.c_str()); if (c) ci = c->ci; - if (!c) { + if (!c) notice_lang(Config.s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); - } else if (is_same ? !(u2 = u) : !(u2 = finduser(target))) { + else if (is_same ? !(u2 = u) : !(u2 = finduser(target))) notice_lang(Config.s_ChanServ, u, NICK_X_NOT_IN_USE, target); - } else if (!is_same ? !check_access(u, ci, CA_BAN) : - !check_access(u, ci, CA_BANME)) { + else if (!is_same ? !check_access(u, ci, CA_BAN) : !check_access(u, ci, CA_BANME)) notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); - } else if (!is_same && (ci->HasFlag(CI_PEACE)) - && (get_access(u2, ci) >= get_access(u, ci))) { + else if (!is_same && (ci->HasFlag(CI_PEACE)) && (get_access(u2, ci) >= get_access(u, ci))) notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); - /* - * Dont ban/kick the user on channels where he is excepted - * to prevent services <-> server wars. - */ - } else if (ModeManager::FindChannelModeByName(CMODE_EXCEPT) && is_excepted(ci, u2)) { + /* + * Dont ban/kick the user on channels where he is excepted + * to prevent services <-> server wars. + */ + else if (ModeManager::FindChannelModeByName(CMODE_EXCEPT) && is_excepted(ci, u2)) notice_lang(Config.s_ChanServ, u, CHAN_EXCEPTED, u2->nick.c_str(), ci->name.c_str()); - } else if (u2->IsProtected()) + else if (u2->IsProtected()) notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); - else { + else + { char mask[BUFSIZE]; get_idealban(ci, u2, mask, sizeof(mask)); @@ -100,7 +96,6 @@ class CommandCSBan : public Command } }; - class CSBan : public Module { public: @@ -114,5 +109,4 @@ class CSBan : public Module } }; - MODULE_INIT(CSBan) diff --git a/src/core/cs_clear.cpp b/src/core/cs_clear.cpp index f331f7a24..088dae741 100644 --- a/src/core/cs_clear.cpp +++ b/src/core/cs_clear.cpp @@ -7,9 +7,8 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ + /*************************************************************************/ #include "module.h" @@ -19,7 +18,6 @@ class CommandCSClear : public Command public: CommandCSClear() : Command("CLEAR", 2, 2) { - } CommandReturn Execute(User *u, const std::vector ¶ms) @@ -51,14 +49,12 @@ class CommandCSClear : public Command c->ClearExcepts(); notice_lang(Config.s_ChanServ, u, CHAN_CLEARED_EXCEPTS, chan); - } else if (ModeManager::FindChannelModeByName(CMODE_INVITE) && what == "invites") { c->ClearInvites(); notice_lang(Config.s_ChanServ, u, CHAN_CLEARED_INVITES, chan); - } else if (what == "modes") { @@ -95,7 +91,7 @@