diff options
author | Adam <Adam@anope.org> | 2013-09-20 21:07:50 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2013-09-20 21:09:35 -0400 |
commit | e5ece18ee7804ed81f1b0f80af30a9aea8320522 (patch) | |
tree | 11ef551790936e22fb54122441fd152566ed0c17 | |
parent | 8641b995c43593289dc4e66cbf980069b80d6d6b (diff) |
Readonlyize many commands
33 files changed, 333 insertions, 49 deletions
diff --git a/include/language.h b/include/language.h index f0dd27782..9447119ad 100644 --- a/include/language.h +++ b/include/language.h @@ -133,7 +133,6 @@ namespace Language #define BOT_DOES_NOT_EXIST _("Bot \002%s\002 does not exist.") #define BOT_NOT_ASSIGNED _("You must assign a bot to the channel before using this command.") #define BOT_NOT_ON_CHANNEL _("Bot is not on channel \002%s\002.") -#define BOT_ASSIGN_READONLY _("Sorry, bot assignment is temporarily disabled.") #define HOST_SET_ERROR _("A vhost must be in the format of a valid hostmask.") #define HOST_SET_IDENT_ERROR _("A vhost ident must be in the format of a valid ident") #define HOST_SET_TOOLONG _("Error! The vhost is too long, please use a host shorter than %d characters.") diff --git a/modules/commands/bs_assign.cpp b/modules/commands/bs_assign.cpp index ba925ad80..96e75682f 100644 --- a/modules/commands/bs_assign.cpp +++ b/modules/commands/bs_assign.cpp @@ -27,7 +27,7 @@ class CommandBSAssign : public Command if (Anope::ReadOnly) { - source.Reply(BOT_ASSIGN_READONLY); + source.Reply(_("Sorry, bot assignment is temporarily disabled.")); return; } @@ -95,7 +95,7 @@ class CommandBSUnassign : public Command { if (Anope::ReadOnly) { - source.Reply(BOT_ASSIGN_READONLY); + source.Reply(_("Sorry, bot assignment is temporarily disabled.")); return; } @@ -159,6 +159,12 @@ class CommandBSSetNoBot : public Command ChannelInfo *ci = ChannelInfo::Find(params[0]); const Anope::string &value = params[1]; + if (Anope::ReadOnly) + { + source.Reply(_("Sorry, bot modification is temporarily disabled.")); + return; + } + if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); diff --git a/modules/commands/bs_set.cpp b/modules/commands/bs_set.cpp index 4e1e77ad1..49ebfa360 100644 --- a/modules/commands/bs_set.cpp +++ b/modules/commands/bs_set.cpp @@ -141,6 +141,12 @@ class CommandBSSetPrivate : public Command BotInfo *bi = BotInfo::Find(params[0], true); const Anope::string &value = params[1]; + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + if (bi == NULL) { source.Reply(BOT_DOES_NOT_EXIST, params[0].c_str()); diff --git a/modules/commands/cs_access.cpp b/modules/commands/cs_access.cpp index ab13b6e7d..0abc5456f 100644 --- a/modules/commands/cs_access.cpp +++ b/modules/commands/cs_access.cpp @@ -732,6 +732,8 @@ class CommandCSLevels : public Command this->OnSyntaxError(source, cmd); else if (!source.AccessFor(ci).HasPriv("FOUNDER") && !source.HasPriv("chanserv/access/modify")) source.Reply(ACCESS_DENIED); + else if (Anope::ReadOnly && !cmd.equals_ci("LIST")) + source.Reply(READ_ONLY_MODE); else if (cmd.equals_ci("SET")) this->DoSet(source, ci, params); else if (cmd.equals_ci("DIS") || cmd.equals_ci("DISABLE")) diff --git a/modules/commands/cs_clone.cpp b/modules/commands/cs_clone.cpp index a1b04d103..c0d33c742 100644 --- a/modules/commands/cs_clone.cpp +++ b/modules/commands/cs_clone.cpp @@ -27,6 +27,12 @@ public: const Anope::string &target = params[1]; Anope::string what = params.size() > 2 ? params[2] : ""; + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + User *u = source.GetUser(); ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) diff --git a/modules/commands/cs_entrymsg.cpp b/modules/commands/cs_entrymsg.cpp index fb21f35d7..fd9da0db8 100644 --- a/modules/commands/cs_entrymsg.cpp +++ b/modules/commands/cs_entrymsg.cpp @@ -203,25 +203,30 @@ class CommandEntryMessage : public Command return; } - if (source.IsFounder(ci) || source.HasCommand("chanserv/set")) + if (Anope::ReadOnly && !params[1].equals_ci("LIST")) { - if (params[1].equals_ci("LIST")) - this->DoList(source, ci); - else if (params[1].equals_ci("CLEAR")) - this->DoClear(source, ci); - else if (params.size() < 3) - this->OnSyntaxError(source, ""); - else if (params[1].equals_ci("ADD")) - this->DoAdd(source, ci, params[2]); - else if (params[1].equals_ci("DEL")) - this->DoDel(source, ci, params[2]); - else - this->OnSyntaxError(source, ""); + source.Reply(READ_ONLY_MODE); + return; } - else + + if (!source.IsFounder(ci) && !source.HasCommand("chanserv/set")) + { source.Reply(ACCESS_DENIED); + return; + } - return; + if (params[1].equals_ci("LIST")) + this->DoList(source, ci); + else if (params[1].equals_ci("CLEAR")) + this->DoClear(source, ci); + else if (params.size() < 3) + this->OnSyntaxError(source, ""); + else if (params[1].equals_ci("ADD")) + this->DoAdd(source, ci, params[2]); + else if (params[1].equals_ci("DEL")) + this->DoDel(source, ci, params[2]); + else + this->OnSyntaxError(source, ""); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override diff --git a/modules/commands/cs_log.cpp b/modules/commands/cs_log.cpp index b74b67466..1eca31f85 100644 --- a/modules/commands/cs_log.cpp +++ b/modules/commands/cs_log.cpp @@ -150,6 +150,12 @@ public: } else if (params.size() > 2) { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + LogSettings *ls = ci->Require<LogSettings>("logsettings"); const Anope::string &command = params[1]; const Anope::string &method = params[2]; diff --git a/modules/commands/cs_mode.cpp b/modules/commands/cs_mode.cpp index 856b43870..f7233eb27 100644 --- a/modules/commands/cs_mode.cpp +++ b/modules/commands/cs_mode.cpp @@ -268,6 +268,12 @@ class CommandCSMode : public Command bool override = !source.AccessFor(ci).HasPriv("MODE"); ModeLocks *modelocks = ci->Require<ModeLocks>("modelocks"); + if (Anope::ReadOnly && !subcommand.equals_ci("LIST")) + { + source.Reply(READ_ONLY_MODE); + return; + } + if ((subcommand.equals_ci("ADD") || subcommand.equals_ci("SET")) && !param.empty()) { /* If setting, remove the existing locks */ diff --git a/modules/commands/cs_set.cpp b/modules/commands/cs_set.cpp index 2d1cdf9aa..251089f9c 100644 --- a/modules/commands/cs_set.cpp +++ b/modules/commands/cs_set.cpp @@ -66,6 +66,12 @@ class CommandCSSetAutoOp : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { @@ -123,6 +129,12 @@ class CommandCSSetBanType : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { @@ -184,6 +196,12 @@ class CommandCSSetDescription : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + ChannelInfo *ci = ChannelInfo::Find(params[0]); const Anope::string ¶m = params.size() > 1 ? params[1] : ""; if (ci == NULL) @@ -240,6 +258,12 @@ class CommandCSSetFounder : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { @@ -303,12 +327,19 @@ class CommandCSSetKeepModes : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); return; } + EventReturn MOD_RESULT; FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); if (MOD_RESULT == EVENT_STOP) @@ -348,12 +379,19 @@ class CommandCSSetPeace : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); return; } + EventReturn MOD_RESULT; FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); if (MOD_RESULT == EVENT_STOP) @@ -413,6 +451,12 @@ class CommandCSSetPersist : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { @@ -565,6 +609,12 @@ class CommandCSSetRestricted : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { @@ -621,6 +671,12 @@ class CommandCSSetSecure : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { @@ -679,6 +735,12 @@ class CommandCSSetSecureFounder : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { @@ -737,6 +799,12 @@ class CommandCSSetSecureOps : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { @@ -793,6 +861,12 @@ class CommandCSSetSignKick : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { @@ -864,6 +938,12 @@ class CommandCSSetSuccessor : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + ChannelInfo *ci = ChannelInfo::Find(params[0]); const Anope::string ¶m = params.size() > 1 ? params[1] : ""; if (ci == NULL) @@ -944,6 +1024,12 @@ class CommandCSSetNoexpire : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { diff --git a/modules/commands/cs_set_misc.cpp b/modules/commands/cs_set_misc.cpp index 4d8efb79b..90a33e2d1 100644 --- a/modules/commands/cs_set_misc.cpp +++ b/modules/commands/cs_set_misc.cpp @@ -100,6 +100,12 @@ class CommandCSSetMisc : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + ChannelInfo *ci = ChannelInfo::Find(params[0]); const Anope::string ¶m = params.size() > 1 ? params[1] : ""; if (ci == NULL) diff --git a/modules/commands/cs_topic.cpp b/modules/commands/cs_topic.cpp index fe393de65..95c83f154 100644 --- a/modules/commands/cs_topic.cpp +++ b/modules/commands/cs_topic.cpp @@ -23,6 +23,12 @@ class CommandCSSetKeepTopic : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { @@ -76,6 +82,12 @@ class CommandCSTopic : public Command void Lock(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + EventReturn MOD_RESULT; FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, "topiclock on")); if (MOD_RESULT == EVENT_STOP) @@ -87,6 +99,12 @@ class CommandCSTopic : public Command void Unlock(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + EventReturn MOD_RESULT; FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, "topiclock off")); if (MOD_RESULT == EVENT_STOP) diff --git a/modules/commands/greet.cpp b/modules/commands/greet.cpp index 90f263557..242e5fb09 100644 --- a/modules/commands/greet.cpp +++ b/modules/commands/greet.cpp @@ -39,7 +39,7 @@ class CommandBSSetGreet : public Command if (Anope::ReadOnly) { - source.Reply(_("Sorry, bot option setting is temporarily disabled.")); + source.Reply(READ_ONLY_MODE); return; } @@ -86,6 +86,12 @@ class CommandNSSetGreet : public Command void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m) { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + const NickAlias *na = NickAlias::Find(user); if (!na) { diff --git a/modules/commands/hs_del.cpp b/modules/commands/hs_del.cpp index cf1a0d84a..78c8433a0 100644 --- a/modules/commands/hs_del.cpp +++ b/modules/commands/hs_del.cpp @@ -22,6 +22,12 @@ class CommandHSDel : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + const Anope::string &nick = params[0]; NickAlias *na = NickAlias::Find(nick); if (na) @@ -56,6 +62,12 @@ class CommandHSDelAll : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + const Anope::string &nick = params[0]; NickAlias *na = NickAlias::Find(nick); if (na) diff --git a/modules/commands/hs_group.cpp b/modules/commands/hs_group.cpp index c07ce297a..5d7ffb76a 100644 --- a/modules/commands/hs_group.cpp +++ b/modules/commands/hs_group.cpp @@ -34,6 +34,12 @@ class CommandHSGroup : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + NickAlias *na = NickAlias::Find(source.GetNick()); if (na && source.GetAccount() == na->nc && na->HasVhost()) { diff --git a/modules/commands/hs_request.cpp b/modules/commands/hs_request.cpp index e7d39f589..9f6f6d3e0 100644 --- a/modules/commands/hs_request.cpp +++ b/modules/commands/hs_request.cpp @@ -82,6 +82,12 @@ class CommandHSRequest : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + User *u = source.GetUser(); NickAlias *na = NickAlias::Find(source.GetNick()); if (!na || na->nc != source.GetAccount()) @@ -183,6 +189,11 @@ class CommandHSActivate : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } const Anope::string &nick = params[0]; @@ -227,6 +238,11 @@ class CommandHSReject : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } const Anope::string &nick = params[0]; const Anope::string &reason = params.size() > 1 ? params[1] : ""; diff --git a/modules/commands/hs_set.cpp b/modules/commands/hs_set.cpp index 5e7f9f2af..f3a7e1e8e 100644 --- a/modules/commands/hs_set.cpp +++ b/modules/commands/hs_set.cpp @@ -22,6 +22,11 @@ class CommandHSSet : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } const Anope::string &nick = params[0]; @@ -123,6 +128,11 @@ class CommandHSSetAll : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } Anope::string nick = params[0]; diff --git a/modules/commands/ms_cancel.cpp b/modules/commands/ms_cancel.cpp index 5b6b0b23f..6ad34f42d 100644 --- a/modules/commands/ms_cancel.cpp +++ b/modules/commands/ms_cancel.cpp @@ -22,6 +22,12 @@ class CommandMSCancel : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + const Anope::string &nname = params[0]; bool ischan; diff --git a/modules/commands/ms_check.cpp b/modules/commands/ms_check.cpp index b912777fe..452a0f337 100644 --- a/modules/commands/ms_check.cpp +++ b/modules/commands/ms_check.cpp @@ -34,7 +34,7 @@ class CommandMSCheck : public Command return; } - MemoInfo *mi = const_cast<MemoInfo *>(&na->nc->memos); + MemoInfo *mi = &na->nc->memos; /* Okay, I know this looks strange but we wanna get the LAST memo, so we have to loop backwards */ diff --git a/modules/commands/ms_del.cpp b/modules/commands/ms_del.cpp index 963239f7f..8876f1d31 100644 --- a/modules/commands/ms_del.cpp +++ b/modules/commands/ms_del.cpp @@ -44,6 +44,11 @@ class CommandMSDel : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } MemoInfo *mi; ChannelInfo *ci = NULL; @@ -60,11 +65,6 @@ class CommandMSDel : public Command source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str()); return; } - else if (Anope::ReadOnly) - { - source.Reply(READ_ONLY_MODE); - return; - } else if (!source.AccessFor(ci).HasPriv("MEMO")) { source.Reply(ACCESS_DENIED); @@ -73,7 +73,7 @@ class CommandMSDel : public Command mi = &ci->memos; } else - mi = const_cast<MemoInfo *>(&source.nc->memos); + mi = &source.nc->memos; if (numstr.empty() || (!isdigit(numstr[0]) && !numstr.equals_ci("ALL") && !numstr.equals_ci("LAST"))) this->OnSyntaxError(source, numstr); else if (mi->memos->empty()) diff --git a/modules/commands/ms_ignore.cpp b/modules/commands/ms_ignore.cpp index 28dd6514d..0194079fe 100644 --- a/modules/commands/ms_ignore.cpp +++ b/modules/commands/ms_ignore.cpp @@ -24,6 +24,12 @@ class CommandMSIgnore : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + Anope::string channel = params[0]; Anope::string command = (params.size() > 1 ? params[1] : ""); Anope::string param = (params.size() > 2 ? params[2] : ""); diff --git a/modules/commands/ms_read.cpp b/modules/commands/ms_read.cpp index 4da9e3478..b32f474ea 100644 --- a/modules/commands/ms_read.cpp +++ b/modules/commands/ms_read.cpp @@ -130,7 +130,7 @@ class CommandMSRead : public Command mi = &ci->memos; } else - mi = const_cast<MemoInfo *>(&source.nc->memos); + mi = &source.nc->memos; if (numstr.empty() || (!numstr.equals_ci("LAST") && !numstr.equals_ci("NEW") && !numstr.is_number_only())) this->OnSyntaxError(source, numstr); diff --git a/modules/commands/ms_rsend.cpp b/modules/commands/ms_rsend.cpp index 235fb06d0..b1bf1f1b8 100644 --- a/modules/commands/ms_rsend.cpp +++ b/modules/commands/ms_rsend.cpp @@ -30,6 +30,12 @@ class CommandMSRSend : public Command if (!memoserv) return; + if (Anope::ReadOnly && !source.IsOper()) + { + source.Reply(MEMO_SEND_DISABLED); + return; + } + const Anope::string &nick = params[0]; const Anope::string &text = params[1]; const NickAlias *na = NULL; diff --git a/modules/commands/ms_send.cpp b/modules/commands/ms_send.cpp index 87603025a..7791ba32d 100644 --- a/modules/commands/ms_send.cpp +++ b/modules/commands/ms_send.cpp @@ -33,6 +33,12 @@ class CommandMSSend : public Command const Anope::string &nick = params[0]; const Anope::string &text = params[1]; + if (Anope::ReadOnly && !source.IsOper()) + { + source.Reply(MEMO_SEND_DISABLED); + return; + } + MemoServService::MemoResult result = memoserv->Send(source.GetNick(), nick, text); if (result == MemoServService::MEMO_SUCCESS) source.Reply(_("Memo sent to \002%s\002."), nick.c_str()); diff --git a/modules/commands/ms_sendall.cpp b/modules/commands/ms_sendall.cpp index 803fbf6ba..3ac47b176 100644 --- a/modules/commands/ms_sendall.cpp +++ b/modules/commands/ms_sendall.cpp @@ -32,12 +32,6 @@ class CommandMSSendAll : public Command const Anope::string &text = params[0]; - if (Anope::ReadOnly) - { - source.Reply(MEMO_SEND_DISABLED); - return; - } - for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it) { const NickCore *nc = it->second; diff --git a/modules/commands/ms_set.cpp b/modules/commands/ms_set.cpp index 21f6d6a7d..03851a5f8 100644 --- a/modules/commands/ms_set.cpp +++ b/modules/commands/ms_set.cpp @@ -110,7 +110,7 @@ class CommandMSSet : public Command return; } user = p1; - mi = const_cast<MemoInfo *>(&na->nc->memos); + mi = &na->nc->memos; nc = na->nc; p1 = p2; p2 = p3; @@ -210,7 +210,7 @@ class CommandMSSet : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { const Anope::string &cmd = params[0]; - MemoInfo *mi = const_cast<MemoInfo *>(&source.nc->memos); + MemoInfo *mi = &source.nc->memos; if (Anope::ReadOnly) source.Reply(_("Sorry, memo option setting is temporarily disabled.")); diff --git a/modules/commands/ms_staff.cpp b/modules/commands/ms_staff.cpp index 20ce265a4..4d26cbfcd 100644 --- a/modules/commands/ms_staff.cpp +++ b/modules/commands/ms_staff.cpp @@ -32,12 +32,6 @@ class CommandMSStaff : public Command const Anope::string &text = params[0]; - if (Anope::ReadOnly) - { - source.Reply(MEMO_SEND_DISABLED); - return; - } - for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it) { const NickCore *nc = it->second; diff --git a/modules/commands/ns_access.cpp b/modules/commands/ns_access.cpp index f21edbf08..8ea925868 100644 --- a/modules/commands/ns_access.cpp +++ b/modules/commands/ns_access.cpp @@ -22,6 +22,12 @@ class CommandNSAccess : public Command return; } + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + if (nc->access.size() >= Config->GetModule(this->owner)->Get<unsigned>("accessmax")) { source.Reply(_("Sorry, you can only have %d access entries for a nickname."), Config->GetModule(this->owner)->Get<unsigned>("accessmax")); @@ -48,6 +54,12 @@ class CommandNSAccess : public Command return; } + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + if (!nc->FindAccess(mask)) { source.Reply(_("\002%s\002 not found on %s's access list."), mask.c_str(), nc->display.c_str()); diff --git a/modules/commands/ns_ajoin.cpp b/modules/commands/ns_ajoin.cpp index 3d30b84d8..c365133a5 100644 --- a/modules/commands/ns_ajoin.cpp +++ b/modules/commands/ns_ajoin.cpp @@ -202,6 +202,8 @@ class CommandNSAJoin : public Command this->DoList(source, nc); else if (param.empty()) this->OnSyntaxError(source, ""); + else if (Anope::ReadOnly) + source.Reply(READ_ONLY_MODE); else if (params[0].equals_ci("ADD")) this->DoAdd(source, nc, param, param2); else if (params[0].equals_ci("DEL")) diff --git a/modules/commands/ns_cert.cpp b/modules/commands/ns_cert.cpp index 014a31a0d..fb2901754 100644 --- a/modules/commands/ns_cert.cpp +++ b/modules/commands/ns_cert.cpp @@ -279,12 +279,14 @@ class CommandNSCert : public Command if (source.nc->HasExt("NS_SUSPENDED")) source.Reply(NICK_X_SUSPENDED, source.nc->display.c_str()); + else if (cmd.equals_ci("LIST")) + return this->DoList(source, nc); + else if (Anope::ReadOnly) + source.Reply(READ_ONLY_MODE); else if (cmd.equals_ci("ADD")) return this->DoAdd(source, nc, mask); else if (cmd.equals_ci("DEL")) return this->DoDel(source, nc, mask); - else if (cmd.equals_ci("LIST")) - return this->DoList(source, nc); else this->OnSyntaxError(source, cmd); } diff --git a/modules/commands/ns_resetpass.cpp b/modules/commands/ns_resetpass.cpp index 6af3af0c2..4134155c4 100644 --- a/modules/commands/ns_resetpass.cpp +++ b/modules/commands/ns_resetpass.cpp @@ -76,6 +76,12 @@ class NSResetPass : public Module { if (command->name == "nickserv/confirm" && params.size() > 1) { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return EVENT_STOP; + } + NickAlias *na = NickAlias::Find(params[0]); ResetInfo *ri = na ? reset.Get(na->nc) : NULL; diff --git a/modules/commands/ns_set.cpp b/modules/commands/ns_set.cpp index 92c2a0d1a..15ab593ad 100644 --- a/modules/commands/ns_set.cpp +++ b/modules/commands/ns_set.cpp @@ -115,6 +115,12 @@ class CommandNSSetPassword : public Command const Anope::string ¶m = params[1]; unsigned len = param.length(); + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + if (source.GetNick().equals_ci(param) || (Config->GetBlock("options")->Get<bool>("strictpasswords") && len < 5)) { source.Reply(MORE_OBSCURE_PASSWORD); @@ -213,6 +219,12 @@ class CommandNSSetAutoOp : public Command void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m) { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + const NickAlias *na = NickAlias::Find(user); if (na == NULL) { @@ -297,6 +309,12 @@ class CommandNSSetDisplay : public Command void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m) { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + const NickAlias *user_na = NickAlias::Find(user), *na = NickAlias::Find(param); if (Config->GetBlock("options")->Get<bool>("nonicknameownership")) @@ -412,6 +430,12 @@ class CommandNSSetEmail : public Command void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m) { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + const NickAlias *na = NickAlias::Find(user); if (!na) { @@ -513,6 +537,12 @@ class CommandNSSetKeepModes : public Command void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m) { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + const NickAlias *na = NickAlias::Find(user); if (!na) { @@ -594,6 +624,12 @@ class CommandNSSetKill : public Command void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m) { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + if (Config->GetBlock("options")->Get<bool>("nonicknameownership")) { source.Reply(_("This command may not be used on this network because nickname ownership is disabled.")); @@ -726,6 +762,12 @@ class CommandNSSetLanguage : public Command void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m) { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + const NickAlias *na = NickAlias::Find(user); if (!na) { @@ -829,6 +871,12 @@ class CommandNSSetMessage : public Command void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m) { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + const NickAlias *na = NickAlias::Find(user); if (!na) { @@ -922,6 +970,12 @@ class CommandNSSetSecure : public Command void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m) { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + const NickAlias *na = NickAlias::Find(user); if (!na) { diff --git a/modules/commands/ns_set_misc.cpp b/modules/commands/ns_set_misc.cpp index 45a857474..844683803 100644 --- a/modules/commands/ns_set_misc.cpp +++ b/modules/commands/ns_set_misc.cpp @@ -103,6 +103,12 @@ class CommandNSSetMisc : public Command void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m) { + if (Anope::ReadOnly) + { + source.Reply(READ_ONLY_MODE); + return; + } + const NickAlias *na = NickAlias::Find(user); if (!na) { diff --git a/modules/commands/ns_suspend.cpp b/modules/commands/ns_suspend.cpp index 9545bdc60..1037cfa88 100644 --- a/modules/commands/ns_suspend.cpp +++ b/modules/commands/ns_suspend.cpp @@ -70,10 +70,7 @@ class CommandNSSuspend : public Command time_t expiry_secs = Config->GetModule(this->owner)->Get<time_t>("suspendexpire"); if (Anope::ReadOnly) - { source.Reply(READ_ONLY_MODE); - return; - } if (expiry[0] != '+') { @@ -162,10 +159,7 @@ class CommandNSUnSuspend : public Command const Anope::string &nick = params[0]; if (Anope::ReadOnly) - { source.Reply(READ_ONLY_MODE); - return; - } NickAlias *na = NickAlias::Find(nick); if (!na) |