X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_cban.cpp;h=250acd2b5dab6e3b303bc97e31e26bddcda9f091;hb=3d0d64933da3d37866fadfa042e34a1125315db6;hp=42cff2850c0be3b2cba8ecfb5b993591ba9b4f95;hpb=5267fb9d362aeb326c9e64f7171c957f76776f90;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_cban.cpp b/src/modules/m_cban.cpp index 42cff2850..250acd2b5 100644 --- a/src/modules/m_cban.cpp +++ b/src/modules/m_cban.cpp @@ -22,6 +22,13 @@ #include "inspircd.h" #include "xline.h" +#include "modules/stats.h" + +enum +{ + // InspIRCd-specific. + ERR_BADCHANNEL = 926 +}; /** Holds a CBAN item */ @@ -31,24 +38,24 @@ private: std::string matchtext; public: - CBan(time_t s_time, long d, const std::string& src, const std::string& re, const std::string& ch) + CBan(time_t s_time, unsigned long d, const std::string& src, const std::string& re, const std::string& ch) : XLine(s_time, d, src, re, "CBAN") , matchtext(ch) { } // XXX I shouldn't have to define this - bool Matches(User *u) + bool Matches(User* u) CXX11_OVERRIDE { return false; } - bool Matches(const std::string &s) + bool Matches(const std::string& s) CXX11_OVERRIDE { return irc::equals(matchtext, s); } - const std::string& Displayable() + const std::string& Displayable() CXX11_OVERRIDE { return matchtext; } @@ -63,12 +70,12 @@ class CBanFactory : public XLineFactory /** Generate a CBAN */ - XLine* Generate(time_t set_time, long duration, std::string source, std::string reason, std::string xline_specific_mask) + XLine* Generate(time_t set_time, unsigned long duration, const std::string& source, const std::string& reason, const std::string& xline_specific_mask) CXX11_OVERRIDE { return new CBan(set_time, duration, source, reason, xline_specific_mask); } - bool AutoApplyToUserList(XLine *x) + bool AutoApplyToUserList(XLine* x) CXX11_OVERRIDE { return false; // No, we apply to channels. } @@ -84,7 +91,7 @@ class CommandCBan : public Command flags_needed = 'o'; this->syntax = " [ :]"; } - CmdResult Handle(const std::vector ¶meters, User *user) + CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE { /* syntax: CBAN #channel time :reason goes here */ /* 'time' is a human-readable timestring, like 2d3h2s. */ @@ -131,7 +138,7 @@ class CommandCBan : public Command return CMD_SUCCESS; } - RouteDescriptor GetRouting(User* user, const std::vector& parameters) + RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE { if (IS_LOCAL(user)) return ROUTE_LOCALONLY; // spanningtree will send ADDLINE @@ -140,13 +147,15 @@ class CommandCBan : public Command } }; -class ModuleCBan : public Module +class ModuleCBan : public Module, public Stats::EventListener { CommandCBan mycommand; CBanFactory f; public: - ModuleCBan() : mycommand(this) + ModuleCBan() + : Stats::EventListener(this) + , mycommand(this) { } @@ -177,7 +186,7 @@ class ModuleCBan : public Module if (rl) { // Channel is banned. - user->WriteNumeric(384, cname, InspIRCd::Format("Cannot join channel, CBANed (%s)", rl->reason.c_str())); + user->WriteNumeric(ERR_BADCHANNEL, cname, InspIRCd::Format("Channel %s is CBANed: %s", cname.c_str(), rl->reason.c_str())); ServerInstance->SNO->WriteGlobalSno('a', "%s tried to join %s which is CBANed (%s)", user->nick.c_str(), cname.c_str(), rl->reason.c_str()); return MOD_RES_DENY;