]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_muteban.cpp
Expand searching in m_httpd_stats, add global handling of GET parameters (#1566)
[user/henk/code/inspircd.git] / src / modules / m_muteban.cpp
index 00c44a6393aec9d45fd6d2fe35cfc82076b0d0b4..61d592b2b9dba45bea8d60905e0f7aa247b1d339 100644 (file)
 
 class ModuleQuietBan : public Module
 {
+ private:
+       bool notifyuser;
+
  public:
-       void init() CXX11_OVERRIDE
+       void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
        {
-               Implementation eventlist[] = { I_OnUserPreMessage, I_On005Numeric };
-               ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
+               ConfigTag* tag = ServerInstance->Config->ConfValue("muteban");
+               notifyuser = tag->getBool("notifyuser", true);
        }
 
        Version GetVersion() CXX11_OVERRIDE
@@ -34,15 +37,21 @@ class ModuleQuietBan : public Module
                return Version("Implements extban +b m: - mute bans",VF_OPTCOMMON|VF_VENDOR);
        }
 
-       ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE
+       ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE
        {
-               if (!IS_LOCAL(user) || target_type != TYPE_CHANNEL)
+               if (!IS_LOCAL(user) || target.type != MessageTarget::TYPE_CHANNEL)
                        return MOD_RES_PASSTHRU;
 
-               Channel* chan = static_cast<Channel*>(dest);
+               Channel* chan = target.Get<Channel>();
                if (chan->GetExtBanStatus(user, 'm') == MOD_RES_DENY && chan->GetPrefixValue(user) < VOICE_VALUE)
                {
-                       user->WriteNumeric(404, "%s %s :Cannot send to channel (you're muted)", user->nick.c_str(), chan->name.c_str());
+                       if (!notifyuser)
+                       {
+                               details.echo_original = true;
+                               return MOD_RES_DENY;
+                       }
+
+                       user->WriteNumeric(ERR_CANNOTSENDTOCHAN, chan->name, "Cannot send to channel (you're muted)");
                        return MOD_RES_DENY;
                }