diff options
Diffstat (limited to 'modules/core')
64 files changed, 299 insertions, 251 deletions
diff --git a/modules/core/bs_act.cpp b/modules/core/bs_act.cpp index 34251cbb2..d52dbdb78 100644 --- a/modules/core/bs_act.cpp +++ b/modules/core/bs_act.cpp @@ -49,8 +49,10 @@ class CommandBSAct : public Command ircdproto->SendAction(ci->bi, ci->name, "%s", message.c_str()); ci->bi->lastmsg = time(NULL); - if (Config->LogBot && !Config->LogChannel.empty() && LogChan && !debug && findchan(Config->LogChannel)) - ircdproto->SendPrivmsg(ci->bi, Config->LogChannel, "ACT %s %s %s", u->nick.c_str(), ci->name.c_str(), message.c_str()); + + // XXX Need to be able to find if someone is overriding this. + Log(LOG_COMMAND, u, this, ci) << message; + return MOD_CONT; } diff --git a/modules/core/bs_assign.cpp b/modules/core/bs_assign.cpp index b1242c857..97b23c0ef 100644 --- a/modules/core/bs_assign.cpp +++ b/modules/core/bs_assign.cpp @@ -59,6 +59,9 @@ class CommandBSAssign : public Command return MOD_CONT; } + bool override = !check_access(u, ci, CA_ASSIGN); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "for " << bi->nick; + bi->Assign(u, ci); notice_lang(Config->s_BotServ, u, BOT_ASSIGN_ASSIGNED, bi->nick.c_str(), ci->name.c_str()); return MOD_CONT; diff --git a/modules/core/bs_badwords.cpp b/modules/core/bs_badwords.cpp index 46b38bf1d..c02ff6570 100644 --- a/modules/core/bs_badwords.cpp +++ b/modules/core/bs_badwords.cpp @@ -53,10 +53,14 @@ class BadwordsDelCallback : public NumberList { User *u; ChannelInfo *ci; + Command *c; unsigned Deleted; + bool override; public: - BadwordsDelCallback(User *_u, ChannelInfo *_ci, const Anope::string &list) : NumberList(list, true), u(_u), ci(_ci), Deleted(0) + BadwordsDelCallback(User *_u, ChannelInfo *_ci, Command *_c, const Anope::string &list) : NumberList(list, true), u(_u), ci(_ci), c(_c), Deleted(0), override(false) { + if (!check_access(u, ci, CA_BADWORDS) && u->Account()->HasPriv("botserv/administration")) + this->override = true; } ~BadwordsDelCallback() @@ -74,6 +78,7 @@ class BadwordsDelCallback : public NumberList if (Number > ci->GetBadWordCount()) return; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, c, ci) << "DEL " << ci->GetBadWord(Number -1 )->word; ++Deleted; ci->EraseBadWord(Number - 1); } @@ -84,6 +89,9 @@ class CommandBSBadwords : public Command private: CommandReturn DoList(User *u, ChannelInfo *ci, const Anope::string &word) { + bool override = !check_access(u, ci, CA_BADWORDS); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "LIST"; + if (!ci->GetBadWordCount()) notice_lang(Config->s_BotServ, u, BOT_BADWORDS_LIST_EMPTY, ci->name.c_str()); else if (!word.empty() && word.find_first_not_of("1234567890,-") == Anope::string::npos) @@ -156,6 +164,8 @@ class CommandBSBadwords : public Command } } + bool override = !check_access(u, ci, CA_BADWORDS); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "ADD " << realword; ci->AddBadWord(realword, type); notice_lang(Config->s_BotServ, u, BOT_BADWORDS_ADDED, realword.c_str(), ci->name.c_str()); @@ -168,7 +178,7 @@ class CommandBSBadwords : public Command /* Special case: is it a number/list? Only do search if it isn't. */ if (!word.empty() && isdigit(word[0]) && word.find_first_not_of("1234567890,-") == Anope::string::npos) { - BadwordsDelCallback list(u, ci, word); + BadwordsDelCallback list(u, ci, this, word); list.Process(); } else @@ -190,6 +200,8 @@ class CommandBSBadwords : public Command return MOD_CONT; } + bool override = !check_access(u, ci, CA_BADWORDS); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "DEL " << badword->word; ci->EraseBadWord(i); notice_lang(Config->s_BotServ, u, BOT_BADWORDS_DELETED, badword->word.c_str(), ci->name.c_str()); @@ -200,6 +212,9 @@ class CommandBSBadwords : public Command CommandReturn DoClear(User *u, ChannelInfo *ci) { + bool override = !check_access(u, ci, CA_BADWORDS); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "CLEAR"; + ci->ClearBadWords(); notice_lang(Config->s_BotServ, u, BOT_BADWORDS_CLEAR); return MOD_CONT; diff --git a/modules/core/bs_bot.cpp b/modules/core/bs_bot.cpp index f001c81a4..5c96ac70c 100644 --- a/modules/core/bs_bot.cpp +++ b/modules/core/bs_bot.cpp @@ -95,10 +95,13 @@ class CommandBSBot : public Command if (!(bi = new BotInfo(nick, user, host, real))) { + // XXX this cant happen? notice_lang(Config->s_BotServ, u, BOT_BOT_CREATION_FAILED); return MOD_CONT; } + Log(LOG_ADMIN, u, this) << "ADD " << bi->GetMask() << " " << bi->realname; + notice_lang(Config->s_BotServ, u, BOT_BOT_ADDED, bi->nick.c_str(), bi->GetIdent().c_str(), bi->host.c_str(), bi->realname.c_str()); FOREACH_MOD(I_OnBotCreate, OnBotCreate(bi)); @@ -260,6 +263,7 @@ class CommandBSBot : public Command } notice_lang(Config->s_BotServ, u, BOT_BOT_CHANGED, oldnick.c_str(), bi->nick.c_str(), bi->GetIdent().c_str(), bi->host.c_str(), bi->realname.c_str()); + Log(LOG_ADMIN, u, this) << "CHANGE " << oldnick << " to " << bi->GetMask() << " " << bi->realname; FOREACH_MOD(I_OnBotChange, OnBotChange(bi)); return MOD_CONT; @@ -294,6 +298,8 @@ class CommandBSBot : public Command XLine x(bi->nick); ircdproto->SendSQLineDel(&x); + Log(LOG_ADMIN, u, this) << "DEL " << bi->nick; + delete bi; notice_lang(Config->s_BotServ, u, BOT_BOT_DELETED, nick.c_str()); return MOD_CONT; diff --git a/modules/core/bs_kick.cpp b/modules/core/bs_kick.cpp index 849efb7d0..2ed3c8639 100644 --- a/modules/core/bs_kick.cpp +++ b/modules/core/bs_kick.cpp @@ -42,6 +42,9 @@ class CommandBSKick : public Command notice_help(Config->s_BotServ, u, BOT_NOT_ASSIGNED); else { + bool override = !check_access(u, ci, CA_SET); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << option << " " << value; + if (option.equals_ci("BADWORDS")) { if (value.equals_ci("ON")) @@ -54,7 +57,7 @@ class CommandBSKick : public Command if (!error.empty() || ci->ttb[TTB_BADWORDS] < 0) { /* leaving the debug behind since we might want to know what these are */ - Alog(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_BADWORDS]; + Log(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_BADWORDS]; /* reset the value back to 0 - TSL */ ci->ttb[TTB_BADWORDS] = 0; notice_lang(Config->s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str()); @@ -85,7 +88,7 @@ class CommandBSKick : public Command ci->ttb[TTB_BOLDS] = convertTo<int16>(ttb, error, false); if (!error.empty() || ci->ttb[TTB_BOLDS] < 0) { - Alog(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_BOLDS]; + Log(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_BOLDS]; ci->ttb[TTB_BOLDS] = 0; notice_lang(Config->s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str()); return MOD_CONT; @@ -118,7 +121,7 @@ class CommandBSKick : public Command ci->ttb[TTB_CAPS] = convertTo<int16>(ttb, error, false); if (!error.empty() || ci->ttb[TTB_CAPS] < 0) { - Alog(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_CAPS]; + Log(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_CAPS]; ci->ttb[TTB_CAPS] = 0; notice_lang(Config->s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str()); return MOD_CONT; @@ -163,7 +166,7 @@ class CommandBSKick : public Command ci->ttb[TTB_COLORS] = convertTo<int16>(ttb, error, false); if (!error.empty() || ci->ttb[TTB_COLORS] < 0) { - Alog(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_COLORS]; + Log(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_COLORS]; ci->ttb[TTB_COLORS] = 0; notice_lang(Config->s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str()); return MOD_CONT; @@ -196,7 +199,7 @@ class CommandBSKick : public Command ci->ttb[TTB_FLOOD] = convertTo<int16>(ttb, error, false); if (!error.empty() || ci->ttb[TTB_FLOOD] < 0) { - Alog(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_FLOOD]; + Log(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_FLOOD]; ci->ttb[TTB_FLOOD] = 0; notice_lang(Config->s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str()); return MOD_CONT; @@ -243,7 +246,7 @@ class CommandBSKick : public Command ci->ttb[TTB_REPEAT] = convertTo<int16>(ttb, error, false); if (!error.empty() || ci->ttb[TTB_REPEAT] < 0) { - Alog(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_REPEAT]; + Log(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_REPEAT]; ci->ttb[TTB_REPEAT] = 0; notice_lang(Config->s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str()); return MOD_CONT; @@ -281,7 +284,7 @@ class CommandBSKick : public Command ci->ttb[TTB_REVERSES] = convertTo<int16>(ttb, error, false); if (!error.empty() || ci->ttb[TTB_REVERSES] < 0) { - Alog(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_REVERSES]; + Log(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_REVERSES]; ci->ttb[TTB_REVERSES] = 0; notice_lang(Config->s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str()); return MOD_CONT; @@ -311,7 +314,7 @@ class CommandBSKick : public Command ci->ttb[TTB_UNDERLINES] = convertTo<int16>(ttb, error, false); if (!error.empty() || ci->ttb[TTB_UNDERLINES] < 0) { - Alog(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_UNDERLINES]; + Log(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_UNDERLINES]; ci->ttb[TTB_UNDERLINES] = 0; notice_lang(Config->s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str()); return MOD_CONT; @@ -341,7 +344,7 @@ class CommandBSKick : public Command ci->ttb[TTB_ITALICS] = convertTo<int16>(ttb, error, false); if (!error.empty() || ci->ttb[TTB_ITALICS] < 0) { - Alog(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_ITALICS]; + Log(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_ITALICS]; ci->ttb[TTB_ITALICS] = 0; notice_lang(Config->s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str()); return MOD_CONT; diff --git a/modules/core/bs_say.cpp b/modules/core/bs_say.cpp index 1b799c415..916cf8fca 100644 --- a/modules/core/bs_say.cpp +++ b/modules/core/bs_say.cpp @@ -55,8 +55,10 @@ class CommandBSSay : public Command ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", text.c_str()); ci->bi->lastmsg = time(NULL); - if (Config->LogBot && !Config->LogChannel.empty() && LogChan && !debug && findchan(Config->LogChannel)) - ircdproto->SendPrivmsg(ci->bi, Config->LogChannel, "SAY %s %s %s", u->nick.c_str(), ci->name.c_str(), text.c_str()); + + // XXX need a way to find if someone is overriding this + Log(LOG_COMMAND, u, this, ci) << text; + return MOD_CONT; } diff --git a/modules/core/bs_set.cpp b/modules/core/bs_set.cpp index 87a15cf66..0ee46a0d5 100644 --- a/modules/core/bs_set.cpp +++ b/modules/core/bs_set.cpp @@ -64,6 +64,9 @@ class CommandBSSet : public Command notice_lang(Config->s_BotServ, u, ACCESS_DENIED); else { + bool override = !check_access(u, ci, CA_SET); + Log(override ? LOG_ADMIN : LOG_COMMAND, u, this, ci) << option << value; + if (option.equals_ci("DONTKICKOPS")) { if (value.equals_ci("ON")) diff --git a/modules/core/bs_unassign.cpp b/modules/core/bs_unassign.cpp index bde37f78e..6b6b28fe9 100644 --- a/modules/core/bs_unassign.cpp +++ b/modules/core/bs_unassign.cpp @@ -36,6 +36,9 @@ class CommandBSUnassign : public Command notice_help(Config->s_BotServ, u, BOT_UNASSIGN_PERSISTANT_CHAN); else { + bool override = !check_access(u, ci, CA_ASSIGN); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "for " << ci->bi->nick; + ci->bi->UnAssign(u, ci); notice_lang(Config->s_BotServ, u, BOT_UNASSIGN_UNASSIGNED, ci->name.c_str()); } diff --git a/modules/core/cs_access.cpp b/modules/core/cs_access.cpp index 5fea57486..c6714cf05 100644 --- a/modules/core/cs_access.cpp +++ b/modules/core/cs_access.cpp @@ -108,12 +108,16 @@ class AccessDelCallback : public NumberList { User *u; ChannelInfo *ci; + Command *c; unsigned Deleted; Anope::string Nicks; bool Denied; + bool override; public: - AccessDelCallback(User *_u, ChannelInfo *_ci, const Anope::string &numlist) : NumberList(numlist, true), u(_u), ci(_ci), Deleted(0), Denied(false) + AccessDelCallback(User *_u, ChannelInfo *_ci, Command *_c, const Anope::string &numlist) : NumberList(numlist, true), u(_u), ci(_ci), c(_c), Deleted(0), Denied(false) { + if (!check_access(u, ci, CA_ACCESS_CHANGE) && u->Account()->HasPriv("chanserv/access/modify")) + this->override = true; } ~AccessDelCallback() @@ -124,7 +128,7 @@ class AccessDelCallback : public NumberList notice_lang(Config->s_ChanServ, u, CHAN_ACCESS_NO_MATCH, ci->name.c_str()); else { - Alog() << Config->s_ChanServ << ": " << u->GetMask() << " (level " << get_access(u, ci) << ") deleted access of user" << (Deleted == 1 ? " " : "s ") << Nicks << " on " << ci->name; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, c, ci) << "for user" << (Deleted == 1 ? " " : "s ") << Nicks; if (Deleted == 1) notice_lang(Config->s_ChanServ, u, CHAN_ACCESS_DELETED_ONE, ci->name.c_str()); @@ -183,6 +187,8 @@ class CommandCSAccess : public Command return MOD_CONT; } + bool override = !check_access(u, ci, CA_ACCESS_CHANGE) || level >= ulev; + NickAlias *na = findnick(nick); if (!na) { @@ -214,7 +220,7 @@ class CommandCSAccess : public Command FOREACH_MOD(I_OnAccessChange, OnAccessChange(ci, u, na->nc, level)); - Alog() << Config->s_ChanServ << ": " << u->GetMask() << " (level " << ulev << ") set access level " << access->level << " to " << na->nick << " (group " << nc->display << ") on channel " << ci->name; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "ADD " << na->nick << "(group: " << nc->display << ") as level " << ulev; notice_lang(Config->s_ChanServ, u, CHAN_ACCESS_LEVEL_CHANGED, nc->display.c_str(), ci->name.c_str(), level); return MOD_CONT; } @@ -229,7 +235,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; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "ADD " << na->nick << "(group: " << nc->display << ") as level " << ulev; notice_lang(Config->s_ChanServ, u, CHAN_ACCESS_ADDED, nc->display.c_str(), ci->name.c_str(), level); return MOD_CONT; @@ -243,7 +249,7 @@ class CommandCSAccess : public Command notice_lang(Config->s_ChanServ, u, CHAN_ACCESS_LIST_EMPTY, ci->name.c_str()); else if (isdigit(nick[0]) && nick.find_first_not_of("1234567890,-") == Anope::string::npos) { - AccessDelCallback list(u, ci, nick); + AccessDelCallback list(u, ci, this, nick); list.Process(); } else @@ -274,7 +280,9 @@ class CommandCSAccess : public Command else { notice_lang(Config->s_ChanServ, u, CHAN_ACCESS_DELETED, access->nc->display.c_str(), ci->name.c_str()); - Alog() << Config->s_ChanServ << ": " << u->GetMask() << " (level " << get_access(u, ci) << ") deleted access of " << na->nick << " (group " << access->nc->display << ") on " << ci->name; + bool override = !check_access(u, ci, CA_ACCESS_CHANGE); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "DEL " << na->nick << "(group: " << access->nc->display << ") from level " << access->level; + FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, u, na->nc)); ci->EraseAccess(i); @@ -375,7 +383,9 @@ class CommandCSAccess : public Command FOREACH_MOD(I_OnAccessClear, OnAccessClear(ci, u)); notice_lang(Config->s_ChanServ, u, CHAN_ACCESS_CLEAR, ci->name.c_str()); - Alog() << Config->s_ChanServ << ": " << u->GetMask() << " (level " << get_access(u, ci) << " cleared access list on " << ci->name; + + bool override = !IsFounder(u, ci); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "CLEAR"; } return MOD_CONT; @@ -471,7 +481,10 @@ class CommandCSLevels : public Command { ci->levels[levelinfo[i].what] = level; FOREACH_MOD(I_OnLevelChange, OnLevelChange(u, ci, i, level)); - Alog() << Config->s_ChanServ << ": " << u->GetMask() << " set level " << levelinfo[i].name << " on channel " << ci->name << " to " << level; + + bool override = !check_access(u, ci, CA_FOUNDER); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "SET " << levelinfo[i].name << " to " << level; + if (level == ACCESS_FOUNDER) notice_lang(Config->s_ChanServ, u, CHAN_LEVELS_CHANGED_FOUNDER, levelinfo[i].name.c_str(), ci->name.c_str()); else @@ -498,7 +511,9 @@ class CommandCSLevels : public Command 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; + bool override = !check_access(u, ci, CA_FOUNDER); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "DISABLE " << levelinfo[i].name; + notice_lang(Config->s_ChanServ, u, CHAN_LEVELS_DISABLED, levelinfo[i].name.c_str(), ci->name.c_str()); return MOD_CONT; } @@ -547,7 +562,10 @@ class CommandCSLevels : public Command { reset_levels(ci); FOREACH_MOD(I_OnLevelChange, OnLevelChange(u, ci, -1, 0)); - Alog() << Config->s_ChanServ << ": " << u->GetMask() << " reset levels definitions on channel " << ci->name; + + bool override = !check_access(u, ci, CA_FOUNDER); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "RESET"; + notice_lang(Config->s_ChanServ, u, CHAN_LEVELS_RESET, ci->name.c_str()); return MOD_CONT; } diff --git a/modules/core/cs_akick.cpp b/modules/core/cs_akick.cpp index c3d3c77b5..5df1a9038 100644 --- a/modules/core/cs_akick.cpp +++ b/modules/core/cs_akick.cpp @@ -138,14 +138,18 @@ class AkickDelCallback : public NumberList { User *u; ChannelInfo *ci; + Command *c; unsigned Deleted; public: - AkickDelCallback(User *_u, ChannelInfo *_ci, const Anope::string &list) : NumberList(list, true), u(_u), ci(_ci), Deleted(0) + AkickDelCallback(User *_u, ChannelInfo *_ci, Command *_c, const Anope::string &list) : NumberList(list, true), u(_u), ci(_ci), c(_c), Deleted(0) { } ~AkickDelCallback() { + bool override = !check_access(u, ci, CA_AKICK); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, c, ci) << "DEL on " << Deleted << " users"; + if (!Deleted) notice_lang(Config->s_ChanServ, u, CHAN_AKICK_NO_MATCH, ci->name.c_str()); else if (Deleted == 1) @@ -266,6 +270,9 @@ class CommandCSAKick : public Command else akick = ci->AddAkick(u->nick, mask, reason); + bool override = !check_access(u, ci, CA_AKICK); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "ADD " << mask << ": " << reason; + FOREACH_MOD(I_OnAkickAdd, OnAkickAdd(u, ci, akick)); notice_lang(Config->s_ChanServ, u, CHAN_AKICK_ADDED, mask.c_str(), ci->name.c_str()); @@ -306,6 +313,9 @@ class CommandCSAKick : public Command return; } + bool override = !check_access(u, ci, CA_AKICK); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "STICK " << akick->mask; + akick->SetFlag(AK_STUCK); notice_lang(Config->s |
