summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2024-03-12 14:12:37 +0000
committerSadie Powell <sadie@witchery.services>2024-03-12 14:12:37 +0000
commite725c880a9ebe862c903dfb217e055ef7cde4a93 (patch)
treec2d0e52dad5fab8f9b8a0f2ccab16c484f6272c2
parentf5abcd1c4cea1c68b82e3d00a2fe479d5557b717 (diff)
Fix expiring channel suspensions.
Closes #386.
-rw-r--r--modules/commands/cs_suspend.cpp28
1 files changed, 20 insertions, 8 deletions
diff --git a/modules/commands/cs_suspend.cpp b/modules/commands/cs_suspend.cpp
index e4fc8afad..ae050e1c6 100644
--- a/modules/commands/cs_suspend.cpp
+++ b/modules/commands/cs_suspend.cpp
@@ -210,6 +210,13 @@ class CSSuspend : public Module
}
};
+ void Expire(ChannelInfo *ci)
+ {
+ suspend.Unset(ci);
+ Log(this) << "Expiring suspend for " << ci->name;
+ }
+
+
bool Show(CommandSource &source, const Anope::string &what) const
{
return source.IsOper() || std::find(show.begin(), show.end(), what) != show.end();
@@ -255,23 +262,28 @@ class CSSuspend : public Module
expire = false;
- if (!si->expires)
- return;
-
- if (si->expires < Anope::CurTime)
+ if (si->expires && si->expires < Anope::CurTime)
{
ci->last_used = Anope::CurTime;
- suspend.Unset(ci);
-
- Log(this) << "Expiring suspend for " << ci->name;
+ Expire(ci);
}
}
EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) anope_override
{
- if (u->HasMode("OPER") || !c->ci || !suspend.HasExt(c->ci))
+ if (u->HasMode("OPER") || !c->ci)
return EVENT_CONTINUE;
+ CSSuspendInfo *si = suspend.Get(c->ci);
+ if (!si)
+ return EVENT_CONTINUE;
+
+ if (si->expires && si->expires < Anope::CurTime)
+ {
+ Expire(c->ci);
+ return EVENT_CONTINUE;
+ }
+
reason = Language::Translate(u, _("This channel may not be used."));
return EVENT_STOP;
}