mirror of
https://github.com/anope/anope.git
synced 2026-07-02 11:26:38 +02:00
Add an event for when nick or channel options are set
This commit is contained in:
+22
-7
@@ -931,6 +931,24 @@ class CoreExport Module : public Extensible
|
||||
virtual void OnSerializableDestruct(Serializable *) { }
|
||||
virtual void OnSerializePtrAssign(Serializable *) { }
|
||||
virtual void OnSerializableUpdate(Serializable *) { }
|
||||
|
||||
/** Called when a chanserv/set command is used
|
||||
* @param source The source of the command
|
||||
* @param cmd The command
|
||||
* @param ci The channel the command was used on
|
||||
* @param setting The setting passed to the command. Probably ON/OFF.
|
||||
* @return EVENT_ALLOW to bypass access checks, EVENT_STOP to halt immediately.
|
||||
*/
|
||||
virtual EventReturn OnSetChannelOption(CommandSource &source, Command *cmd, ChannelInfo *ci, const Anope::string &setting) { return EVENT_CONTINUE; }
|
||||
|
||||
/** Called when a nickserv/set command is used.
|
||||
* @param source The source of the command
|
||||
* @param cmd The command
|
||||
* @param nc The nickcore being modifed
|
||||
* @param setting The setting passed to the command. Probably ON/OFF.
|
||||
* @return EVENT_STOP to halt immediately
|
||||
*/
|
||||
virtual EventReturn OnSetNickOption(CommandSource &source, Command *cmd, NickCore *nc, const Anope::string &setting) { return EVENT_CONTINUE; }
|
||||
};
|
||||
|
||||
/** Implementation-specific flags which may be set in ModuleManager::Attach()
|
||||
@@ -940,18 +958,15 @@ enum Implementation
|
||||
I_BEGIN,
|
||||
/* NickServ */
|
||||
I_OnPreNickExpire, I_OnNickExpire, I_OnNickForbidden, I_OnNickGroup, I_OnNickLogout, I_OnNickIdentify, I_OnNickDrop,
|
||||
I_OnNickRegister, I_OnNickSuspended, I_OnNickUnsuspended,
|
||||
I_OnDelNick, I_OnDelCore, I_OnChangeCoreDisplay,
|
||||
I_OnNickClearAccess, I_OnNickAddAccess, I_OnNickEraseAccess,
|
||||
I_OnNickClearCert, I_OnNickAddCert, I_OnNickEraseCert,
|
||||
I_OnNickInfo, I_OnCheckAuthentication,
|
||||
I_OnNickUpdate,
|
||||
I_OnNickRegister, I_OnNickSuspended, I_OnNickUnsuspended, I_OnDelNick, I_OnDelCore, I_OnChangeCoreDisplay,
|
||||
I_OnNickClearAccess, I_OnNickAddAccess, I_OnNickEraseAccess, I_OnNickClearCert, I_OnNickAddCert, I_OnNickEraseCert,
|
||||
I_OnNickInfo, I_OnCheckAuthentication, I_OnNickUpdate, I_OnSetNickOption,
|
||||
|
||||
/* ChanServ */
|
||||
I_OnChanSuspend, I_OnChanDrop, I_OnPreChanExpire, I_OnChanExpire, I_OnAccessAdd,
|
||||
I_OnAccessDel, I_OnAccessClear, I_OnLevelChange, I_OnChanRegistered, I_OnChanUnsuspend, I_OnCreateChan, I_OnDelChan, I_OnChannelCreate,
|
||||
I_OnChannelDelete, I_OnAkickAdd, I_OnAkickDel, I_OnCheckKick, I_OnCheckModes,
|
||||
I_OnChanInfo, I_OnCheckPriv, I_OnGroupCheckPriv,
|
||||
I_OnChanInfo, I_OnCheckPriv, I_OnGroupCheckPriv, I_OnSetChannelOption,
|
||||
|
||||
/* BotServ */
|
||||
I_OnBotJoin, I_OnBotKick, I_OnBotCreate, I_OnBotChange, I_OnBotDelete, I_OnBotAssign, I_OnBotUnAssign,
|
||||
|
||||
@@ -31,7 +31,12 @@ class CommandCSSetAutoOp : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1]));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
|
||||
if (MOD_RESULT != EVENT_ALLOW && source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
|
||||
@@ -31,7 +31,12 @@ class CommandCSSetBanType : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1]));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
|
||||
if (MOD_RESULT != EVENT_ALLOW && source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
|
||||
@@ -31,7 +31,12 @@ class CommandCSSetChanstats : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1]));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
|
||||
if (MOD_RESULT != EVENT_ALLOW && source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
|
||||
@@ -31,7 +31,12 @@ class CommandCSSetDescription : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1]));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
|
||||
if (MOD_RESULT != EVENT_ALLOW && source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
|
||||
@@ -31,7 +31,12 @@ class CommandCSSetFounder : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1]));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
|
||||
if (MOD_RESULT != EVENT_ALLOW && source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
|
||||
@@ -31,7 +31,12 @@ class CommandCSSetKeepTopic : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1]));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
|
||||
if (MOD_RESULT != EVENT_ALLOW && source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
|
||||
@@ -81,7 +81,13 @@ class CommandCSSetMisc : public Command
|
||||
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
|
||||
return;
|
||||
}
|
||||
else if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1]));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
|
||||
if (MOD_RESULT != EVENT_ALLOW && source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
|
||||
@@ -30,8 +30,12 @@ class CommandCSSetPeace : public Command
|
||||
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
|
||||
return;
|
||||
}
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1]));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
|
||||
if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
if (MOD_RESULT != EVENT_ALLOW && source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
|
||||
@@ -31,7 +31,12 @@ class CommandCSSetPersist : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1]));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
|
||||
if (MOD_RESULT != EVENT_ALLOW && source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
|
||||
@@ -31,7 +31,12 @@ class CommandCSSetPrivate : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1]));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
|
||||
if (MOD_RESULT != EVENT_ALLOW && source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
|
||||
@@ -30,7 +30,12 @@ class CommandCSSetRestricted : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1]));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
|
||||
if (MOD_RESULT != EVENT_ALLOW && source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
|
||||
@@ -31,7 +31,12 @@ class CommandCSSetSecure : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1]));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
|
||||
if (MOD_RESULT != EVENT_ALLOW && source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
|
||||
@@ -31,8 +31,12 @@ class CommandCSSetSecureFounder : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1]));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
|
||||
if (source.permission.empty() && ci->HasFlag(CI_SECUREFOUNDER) ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER"))
|
||||
if (MOD_RESULT != EVENT_ALLOW && source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
|
||||
@@ -31,7 +31,12 @@ class CommandCSSetSecureOps : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1]));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
|
||||
if (MOD_RESULT != EVENT_ALLOW && source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
|
||||
@@ -31,7 +31,12 @@ class CommandCSSetSignKick : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1]));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
|
||||
if (MOD_RESULT != EVENT_ALLOW && source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
|
||||
@@ -31,16 +31,24 @@ class CommandCSSetSuccessor : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1]));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
}
|
||||
|
||||
if (source.permission.empty() && ci->HasFlag(CI_SECUREFOUNDER) ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER"))
|
||||
if (MOD_RESULT != EVENT_ALLOW && source.permission.empty())
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
if (!source.AccessFor(ci).HasPriv("SET"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ci->HasFlag(CI_SECUREFOUNDER) ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
NickCore *nc;
|
||||
|
||||
@@ -31,7 +31,12 @@ class CommandCSSetTopicLock : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1]));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
|
||||
if (MOD_RESULT != EVENT_ALLOW && source.permission.empty() && !source.AccessFor(ci).HasPriv("SET"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
|
||||
@@ -31,6 +31,11 @@ class CommandNSSetAutoOp : public Command
|
||||
return;
|
||||
}
|
||||
NickCore *nc = na->nc;
|
||||
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
|
||||
if (param.equals_ci("ON"))
|
||||
{
|
||||
|
||||
@@ -30,6 +30,11 @@ class CommandNSSetChanstats : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, na->nc, param));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
|
||||
if (param.equals_ci("ON"))
|
||||
{
|
||||
na->nc->SetFlag(NI_STATS);
|
||||
|
||||
@@ -37,6 +37,11 @@ class CommandNSSetDisplay : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, user_na->nc, param));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
|
||||
change_core_display(user_na->nc, na->nick);
|
||||
source.Reply(NICK_SET_DISPLAY_CHANGED, user_na->nc->display.c_str());
|
||||
}
|
||||
|
||||
@@ -78,6 +78,11 @@ class CommandNSSetEmail : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
|
||||
if (!param.empty() && Config->NSConfirmEmailChanges && !source.IsServicesOper())
|
||||
{
|
||||
source.nc->Extend("ns_set_email", new ExtensibleItemClass<Anope::string>(param));
|
||||
|
||||
@@ -32,6 +32,11 @@ class CommandNSSetGreet : public Command
|
||||
}
|
||||
NickCore *nc = na->nc;
|
||||
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
|
||||
if (!param.empty())
|
||||
{
|
||||
nc->greet = param;
|
||||
|
||||
@@ -32,6 +32,11 @@ class CommandNSSetHide : public Command
|
||||
}
|
||||
NickCore *nc = na->nc;
|
||||
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
|
||||
Anope::string onmsg, offmsg;
|
||||
NickCoreFlag flag;
|
||||
|
||||
|
||||
@@ -32,6 +32,11 @@ class CommandNSSetKill : public Command
|
||||
}
|
||||
NickCore *nc = na->nc;
|
||||
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
|
||||
if (param.equals_ci("ON"))
|
||||
{
|
||||
nc->SetFlag(NI_KILLPROTECT);
|
||||
|
||||
@@ -32,6 +32,11 @@ class CommandNSSetLanguage : public Command
|
||||
}
|
||||
NickCore *nc = na->nc;
|
||||
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
|
||||
for (unsigned j = 0; j < languages.size(); ++j)
|
||||
{
|
||||
if (param == "en" || languages[j] == param)
|
||||
|
||||
@@ -38,6 +38,11 @@ class CommandNSSetMessage : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
|
||||
if (param.equals_ci("ON"))
|
||||
{
|
||||
nc->SetFlag(NI_MSG);
|
||||
|
||||
@@ -84,6 +84,11 @@ class CommandNSSetMisc : public Command
|
||||
}
|
||||
NickCore *nc = na->nc;
|
||||
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
|
||||
Anope::string scommand = GetAttribute(source.command);
|
||||
Anope::string key = "ns_set_misc:" + scommand;
|
||||
nc->Shrink(key);
|
||||
|
||||
@@ -32,6 +32,11 @@ class CommandNSSetPrivate : public Command
|
||||
}
|
||||
NickCore *nc = na->nc;
|
||||
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
|
||||
if (param.equals_ci("ON"))
|
||||
{
|
||||
nc->SetFlag(NI_PRIVATE);
|
||||
|
||||
@@ -32,6 +32,11 @@ class CommandNSSetSecure : public Command
|
||||
}
|
||||
NickCore *nc = na->nc;
|
||||
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
|
||||
if (param.equals_ci("ON"))
|
||||
{
|
||||
nc->SetFlag(NI_SECURE);
|
||||
|
||||
Reference in New Issue
Block a user