diff options
Diffstat (limited to 'modules/commands/bs_kick.cpp')
-rw-r--r-- | modules/commands/bs_kick.cpp | 97 |
1 files changed, 46 insertions, 51 deletions
diff --git a/modules/commands/bs_kick.cpp b/modules/commands/bs_kick.cpp index eeeaf4b22..051400d16 100644 --- a/modules/commands/bs_kick.cpp +++ b/modules/commands/bs_kick.cpp @@ -20,8 +20,8 @@ struct KickerDataImpl : KickerData KickerDataImpl(Extensible *obj) { amsgs = badwords = bolds = caps = colors = flood = italics = repeat = reverses = underlines = false; - for (int16_t i = 0; i < TTB_SIZE; ++i) - ttb[i] = 0; + for (auto &ttbtype : ttb) + ttbtype = 0; capsmin = capspercent = 0; floodlines = floodsecs = 0; repeattimes = 0; @@ -29,7 +29,7 @@ struct KickerDataImpl : KickerData dontkickops = dontkickvoices = false; } - void Check(ChannelInfo *ci) anope_override + void Check(ChannelInfo *ci) override { if (amsgs || badwords || bolds || caps || colors || flood || italics || repeat || reverses || underlines || dontkickops || dontkickvoices) return; @@ -41,7 +41,7 @@ struct KickerDataImpl : KickerData { ExtensibleItem(Module *m, const Anope::string &ename) : ::ExtensibleItem<KickerDataImpl>(m, ename) { } - void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const anope_override + void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const override { if (s->GetSerializableType()->GetName() != "ChannelInfo") return; @@ -69,11 +69,11 @@ struct KickerDataImpl : KickerData data.SetType("repeattimes", Serialize::Data::DT_INT); data["repeattimes"] << kd->repeattimes; data.SetType("dontkickops", Serialize::Data::DT_INT); data["dontkickops"] << kd->dontkickops; data.SetType("dontkickvoices", Serialize::Data::DT_INT); data["dontkickvoices"] << kd->dontkickvoices; - for (int16_t i = 0; i < TTB_SIZE; ++i) - data["ttb"] << kd->ttb[i] << " "; + for (auto ttbtype : kd->ttb) + data["ttb"] << ttbtype << " "; } - void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) anope_override + void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) override { if (s->GetSerializableType()->GetName() != "ChannelInfo") return; @@ -124,23 +124,20 @@ class CommandBSKick : public Command this->SetSyntax(_("\037option\037 \037channel\037 {\037ON|OFF\037} [\037settings\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { this->OnSyntaxError(source, ""); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); source.Reply(_("Configures bot kickers. \037option\037 can be one of:")); Anope::string this_name = source.command; - for (CommandInfo::map::const_iterator it = source.service->commands.begin(), it_end = source.service->commands.end(); it != it_end; ++it) + for (const auto &[c_name, info] : source.service->commands) { - const Anope::string &c_name = it->first; - const CommandInfo &info = it->second; - if (c_name.find_ci(this_name + " ") == 0) { ServiceReference<Command> command("Command", info.name); @@ -169,9 +166,9 @@ class CommandBSKickBase : public Command { } - virtual void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override = 0; + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override = 0; - virtual bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override = 0; + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override = 0; protected: bool CheckArguments(CommandSource &source, const std::vector<Anope::string> ¶ms, ChannelInfo* &ci) @@ -256,7 +253,7 @@ class CommandBSKickAMSG : public CommandBSKickBase this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { ChannelInfo *ci; if (CheckArguments(source, params, ci)) @@ -267,7 +264,7 @@ class CommandBSKickAMSG : public CommandBSKickBase } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -292,7 +289,7 @@ class CommandBSKickBadwords : public CommandBSKickBase this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { ChannelInfo *ci; if (CheckArguments(source, params, ci)) @@ -304,7 +301,7 @@ class CommandBSKickBadwords : public CommandBSKickBase } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -331,7 +328,7 @@ class CommandBSKickBolds : public CommandBSKickBase this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { ChannelInfo *ci; if (CheckArguments(source, params, ci)) @@ -342,7 +339,7 @@ class CommandBSKickBolds : public CommandBSKickBase } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -365,7 +362,7 @@ class CommandBSKickCaps : public CommandBSKickBase this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037 [\037min\037 [\037percent\037]]]\002")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { ChannelInfo *ci; if (!CheckArguments(source, params, ci)) @@ -433,7 +430,7 @@ class CommandBSKickCaps : public CommandBSKickBase kd->Check(ci); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -461,7 +458,7 @@ class CommandBSKickColors : public CommandBSKickBase this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { ChannelInfo *ci; if (CheckArguments(source, params, ci)) @@ -472,7 +469,7 @@ class CommandBSKickColors : public CommandBSKickBase } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -495,7 +492,7 @@ class CommandBSKickFlood : public CommandBSKickBase this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037 [\037ln\037 [\037secs\037]]]\002")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { ChannelInfo *ci; if (!CheckArguments(source, params, ci)) @@ -568,7 +565,7 @@ class CommandBSKickFlood : public CommandBSKickBase kd->Check(ci); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -593,7 +590,7 @@ class CommandBSKickItalics : public CommandBSKickBase this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { ChannelInfo *ci; if (CheckArguments(source, params, ci)) @@ -604,7 +601,7 @@ class CommandBSKickItalics : public CommandBSKickBase } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -627,7 +624,7 @@ class CommandBSKickRepeat : public CommandBSKickBase this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037 [\037num\037]]\002")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { ChannelInfo *ci; if (!CheckArguments(source, params, ci)) @@ -703,7 +700,7 @@ class CommandBSKickRepeat : public CommandBSKickBase kd->Check(ci); } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -728,7 +725,7 @@ class CommandBSKickReverses : public CommandBSKickBase this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { ChannelInfo *ci; if (CheckArguments(source, params, ci)) @@ -739,7 +736,7 @@ class CommandBSKickReverses : public CommandBSKickBase } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -762,7 +759,7 @@ class CommandBSKickUnderlines : public CommandBSKickBase this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { ChannelInfo *ci; if (CheckArguments(source, params, ci)) @@ -773,7 +770,7 @@ class CommandBSKickUnderlines : public CommandBSKickBase } } - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override + bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { this->SendSyntax(source); source.Reply(" "); @@ -796,7 +793,7 @@ class CommandBSSetDontKickOps : public Command this->SetSyntax(_("\037channel\037 {ON | OFF}")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) @@ -841,7 +838,7 @@ class CommandBSSetDontKickOps : public Command kd->Check(ci); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(_(" \n" @@ -861,7 +858,7 @@ class CommandBSSetDontKickVoices : public Command this->SetSyntax(_("\037channel\037 {ON | OFF}")); } - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) @@ -906,7 +903,7 @@ class CommandBSSetDontKickVoices : public Command kd->Check(ci); } - bool OnHelp(CommandSource &source, const Anope::string &) anope_override + bool OnHelp(CommandSource &source, const Anope::string &) override { this->SendSyntax(source); source.Reply(_(" \n" @@ -928,8 +925,8 @@ struct BanData Data() { last_use = 0; - for (int i = 0; i < TTB_SIZE; ++i) - this->ttb[i] = 0; + for (auto &ttbtype : this->ttb) + ttbtype = 0; } }; @@ -993,14 +990,12 @@ class BanDataPurger : public Timer public: BanDataPurger(Module *o) : Timer(o, 300, Anope::CurTime, true) { } - void Tick(time_t) anope_override + void Tick(time_t) override { Log(LOG_DEBUG) << "bs_main: Running bandata purger"; - for (channel_map::iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it) + for (auto &[_, c] : ChannelList) { - Channel *c = it->second; - BanData *bd = c->GetExt<BanData>("bandata"); if (bd != NULL) { @@ -1049,7 +1044,7 @@ class BSKick : public Module UserData *ud = userdata.Require(uc); return ud; - } + } void check_ban(ChannelInfo *ci, User *u, KickerData *kd, int ttbtype) { @@ -1110,7 +1105,7 @@ class BSKick : public Module } - void OnBotInfo(CommandSource &source, BotInfo *bi, ChannelInfo *ci, InfoFormatter &info) anope_override + void OnBotInfo(CommandSource &source, BotInfo *bi, ChannelInfo *ci, InfoFormatter &info) override { if (!ci) return; @@ -1225,7 +1220,7 @@ class BSKick : public Module info.AddOption(_("Voices protection")); } - void OnPrivmsg(User *u, Channel *c, Anope::string &msg) anope_override + void OnPrivmsg(User *u, Channel *c, Anope::string &msg) override { /* Now we can make kicker stuff. We try to order the checks * from the fastest one to the slowest one, since there's @@ -1308,11 +1303,11 @@ class BSKick : public Module { int i = 0, l = 0; - for (unsigned j = 0, end = realbuf.length(); j < end; ++j) + for (auto chr : realbuf) { - if (isupper(realbuf[j])) + if (isupper(chr)) ++i; - else if (islower(realbuf[j])) + else if (islower(chr)) ++l; } |