summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/botserv.example.conf1
-rw-r--r--include/regchannel.h2
-rw-r--r--modules/commands/bs_set.cpp81
-rw-r--r--src/regchannel.cpp3
4 files changed, 86 insertions, 1 deletions
diff --git a/data/botserv.example.conf b/data/botserv.example.conf
index 19946c42a..b0cc513ae 100644
--- a/data/botserv.example.conf
+++ b/data/botserv.example.conf
@@ -274,6 +274,7 @@ command { service = "BotServ"; name = "KICK UNDERLINES"; command = "botserv/kick
*/
module { name = "bs_set" }
command { service = "BotServ"; name = "SET"; command = "botserv/set"; }
+command { service = "BotServ"; name = "SET BANEXPIRE"; command = "botserv/set/banexpire"; }
command { service = "BotServ"; name = "SET DONTKICKOPS"; command = "botserv/set/dontkickops"; }
command { service = "BotServ"; name = "SET DONTKICKVOICES"; command = "botserv/set/dontkickvoices"; }
command { service = "BotServ"; name = "SET FANTASY"; command = "botserv/set/fantasy"; }
diff --git a/include/regchannel.h b/include/regchannel.h
index c20f874e1..395794594 100644
--- a/include/regchannel.h
+++ b/include/regchannel.h
@@ -198,6 +198,8 @@ class CoreExport ChannelInfo : public Serializable, public Extensible
int16_t floodlines, floodsecs; /* For FLOOD kicker */
int16_t repeattimes; /* For REPEAT kicker */
+ time_t banexpire; /* Time bans expire in */
+
/** Constructor
* @param chname The channel name
*/
diff --git a/modules/commands/bs_set.cpp b/modules/commands/bs_set.cpp
index 514ee3467..41c84bf87 100644
--- a/modules/commands/bs_set.cpp
+++ b/modules/commands/bs_set.cpp
@@ -54,6 +54,75 @@ class CommandBSSet : public Command
}
};
+class CommandBSSetBanExpire : public Command
+{
+ public:
+ class Timer : public CallBack
+ {
+ Anope::string chname;
+ Anope::string mask;
+
+ public:
+ Timer(Module *creator, const Anope::string &ch, const Anope::string &bmask, time_t t) : CallBack(creator, t), chname(ch), mask(bmask) { }
+
+ void Tick(time_t)
+ {
+ Channel *c = Channel::Find(chname);
+ if (c)
+ c->RemoveMode(NULL, "BAN", mask);
+ }
+ };
+
+ CommandBSSetBanExpire(Module *creator, const Anope::string &sname = "botserv/set/banexpire") : Command(creator, sname, 2, 2)
+ {
+ this->SetDesc(_("Configures the time bot bans expire in"));
+ this->SetSyntax(_("\037channel\037 \037time\037"));
+ }
+
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
+ {
+ const Anope::string &chan = params[0];
+ const Anope::string &arg = params[1];
+
+ ChannelInfo *ci = ChannelInfo::Find(chan);
+ if (ci == NULL)
+ {
+ source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str());
+ return;
+ }
+
+ AccessGroup access = source.AccessFor(ci);
+ if (!source.HasPriv("botserv/administration") && !access.HasPriv("SET"))
+ {
+ source.Reply(ACCESS_DENIED);
+ return;
+ }
+
+ if (Anope::ReadOnly)
+ {
+ source.Reply(_("Sorry, bot option setting is temporarily disabled."));
+ return;
+ }
+
+ ci->banexpire = Anope::DoTime(arg);
+ if (!ci->banexpire)
+ source.Reply(_("Bot bans will no longer automatically expire."));
+ else
+ source.Reply(_("Bot bans will automatically expire after %s."), Anope::Duration(ci->banexpire, source.GetAccount()).c_str());
+ }
+
+ bool OnHelp(CommandSource &source, const Anope::string &) anope_override
+ {
+ this->SendSyntax(source);
+ source.Reply(_(" \n"
+ "Sets the time bot bans expire in. If enabled, any bans placed by\n"
+ "bots, such as flood kicker, badwords kicker, etc. will automatically\n"
+ "be removed after the given time. Set to 0 to disable bans from\n"
+ "automatically expiring."));
+ return true;
+ }
+};
+
class CommandBSSetDontKickOps : public Command
{
public:
@@ -413,6 +482,7 @@ class CommandBSSetPrivate : public Command
class BSSet : public Module
{
CommandBSSet commandbsset;
+ CommandBSSetBanExpire commandbssetbanexpire;
CommandBSSetDontKickOps commandbssetdontkickops;
CommandBSSetDontKickVoices commandbssetdontkickvoices;
CommandBSSetFantasy commandbssetfantasy;
@@ -421,11 +491,20 @@ class BSSet : public Module
public:
BSSet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
- commandbsset(this), commandbssetdontkickops(this), commandbssetdontkickvoices(this),
+ commandbsset(this), commandbssetbanexpire(this), commandbssetdontkickops(this), commandbssetdontkickvoices(this),
commandbssetfantasy(this), commandbssetnobot(this), commandbssetprivate(this)
{
this->SetAuthor("Anope");
+ ModuleManager::Attach(I_OnBotBan, this);
+ }
+
+ void OnBotBan(User *u, ChannelInfo *ci, const Anope::string &mask) anope_override
+ {
+ if (!ci->banexpire)
+ return;
+
+ new CommandBSSetBanExpire::Timer(this, ci->name, mask, ci->banexpire);
}
};
diff --git a/src/regchannel.cpp b/src/regchannel.cpp
index 2af652d8e..bc7505761 100644
--- a/src/regchannel.cpp
+++ b/src/regchannel.cpp
@@ -274,6 +274,7 @@ ChannelInfo::ChannelInfo(const Anope::string &chname) : Serializable("ChannelInf
this->capsmin = this->capspercent = 0;
this->floodlines = this->floodsecs = 0;
this->repeattimes = 0;
+ this->banexpire = 0;
this->bi = NULL;
this->last_topic_setter = Config->ChanServ;
@@ -430,6 +431,7 @@ void ChannelInfo::Serialize(Serialize::Data &data) const
data.SetType("floodlines", Serialize::Data::DT_INT); data["floodlines"] << this->floodlines;
data.SetType("floodsecs", Serialize::Data::DT_INT); data["floodsecs"] << this->floodsecs;
data.SetType("repeattimes", Serialize::Data::DT_INT); data["repeattimes"] << this->repeattimes;
+ data.SetType("banexpire", Serialize::Data::DT_INT); data["banexpire"] << this->banexpire;
data["memomax"] << this->memos.memomax;
for (unsigned i = 0; i < this->memos.ignores.size(); ++i)
data["memoignores"] << this->memos.ignores[i] << " ";
@@ -483,6 +485,7 @@ Serializable* ChannelInfo::Unserialize(Serializable *obj, Serialize::Data &data)
data["floodlines"] >> ci->floodlines;
data["floodsecs"] >> ci->floodsecs;
data["repeattimes"] >> ci->repeattimes;
+ data["banexpire"] >> ci->banexpire;
data["memomax"] >> ci->memos.memomax;
{
Anope::string buf;