]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_services_account.cpp
Fix NICKLOCK/SANICK errors with Q:lined nicks
[user/henk/code/inspircd.git] / src / modules / m_services_account.cpp
index 45baaf90e0fa834012a494f1a175d6b769740808..3f1913de4ed7afb57d6d0be7adb013169e59361f 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2010 InspIRCd Development Team
  * See: http://wiki.inspircd.org/Credits
  *
  * This program is free but copyrighted software; see
@@ -27,7 +27,7 @@ class Channel_r : public ModeHandler
        ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
        {
                // only a u-lined server may add or remove the +r mode.
-               if (IS_REMOTE(source) || ServerInstance->ULine(source->nick.c_str()) || ServerInstance->ULine(source->server))
+               if (!IS_LOCAL(source) || ServerInstance->ULine(source->nick.c_str()) || ServerInstance->ULine(source->server))
                {
                        // Only change the mode if it's not redundant
                        if ((adding && !channel->IsModeSet('r')) || (!adding && channel->IsModeSet('r')))
@@ -56,7 +56,7 @@ class User_r : public ModeHandler
 
        ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
        {
-               if (IS_REMOTE(source) || ServerInstance->ULine(source->nick.c_str()) || ServerInstance->ULine(source->server))
+               if (!IS_LOCAL(source) || ServerInstance->ULine(source->nick.c_str()) || ServerInstance->ULine(source->server))
                {
                        if ((adding && !dest->IsModeSet('r')) || (!adding && dest->IsModeSet('r')))
                        {
@@ -104,22 +104,25 @@ class ModuleServicesAccount : public Module
        AUser_R m3;
        Channel_r m4;
        User_r m5;
-       StringExtItem accountname;
+       AccountExtItem accountname;
  public:
        ModuleServicesAccount() : m1(this), m2(this), m3(this), m4(this), m5(this),
                accountname("accountname", this)
        {
+       }
 
-               if (!ServerInstance->Modes->AddMode(&m1) || !ServerInstance->Modes->AddMode(&m2) ||
-                       !ServerInstance->Modes->AddMode(&m3) || !ServerInstance->Modes->AddMode(&m4) ||
-                       !ServerInstance->Modes->AddMode(&m5))
-                       throw ModuleException("Some other module has claimed our modes!");
-
-               Extensible::Register(&accountname);
+       void init()
+       {
+               ServerInstance->Modules->AddService(m1);
+               ServerInstance->Modules->AddService(m2);
+               ServerInstance->Modules->AddService(m3);
+               ServerInstance->Modules->AddService(m4);
+               ServerInstance->Modules->AddService(m5);
+               ServerInstance->Modules->AddService(accountname);
                Implementation eventlist[] = { I_OnWhois, I_OnUserPreMessage, I_OnUserPreNotice, I_OnUserPreJoin, I_OnCheckBan,
-                       I_OnSyncUser, I_OnUserQuit, I_OnDecodeMetaData, I_On005Numeric, I_OnUserPostNick };
+                       I_OnDecodeMetaData, I_On005Numeric, I_OnUserPostNick };
 
-               ServerInstance->Modules->Attach(eventlist, this, 10);
+               ServerInstance->Modules->Attach(eventlist, this, 8);
        }
 
        void On005Numeric(std::string &t)
@@ -173,8 +176,10 @@ class ModuleServicesAccount : public Module
                if (target_type == TYPE_CHANNEL)
                {
                        Channel* c = (Channel*)dest;
+                       ModResult res;
+                       FIRST_MOD_RESULT(OnChannelRestrictionApply, res, (user,c,"regmoderated"));
 
-                       if (c->IsModeSet('M') && !is_registered)
+                       if (c->IsModeSet('M') && !is_registered && res != MOD_RES_ALLOW)
                        {
                                // user messaging a +M channel and is not registered
                                user->WriteNumeric(477, ""+std::string(user->nick)+" "+std::string(c->name)+" :You need to be identified to a registered account to message this channel");
@@ -273,7 +278,7 @@ class ModuleServicesAccount : public Module
 
        Version GetVersion()
        {
-               return Version("Povides support for ircu-style services accounts, including chmode +R, etc.",VF_COMMON|VF_VENDOR,API_VERSION);
+               return Version("Povides support for ircu-style services accounts, including chmode +R, etc.",VF_OPTCOMMON|VF_VENDOR);
        }
 };