]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_services_account.cpp
Convert WriteNumeric() calls to pass the parameters of the numeric as method parameters
[user/henk/code/inspircd.git] / src / modules / m_services_account.cpp
index 4ad339fcbca7c43830258dd912b2c25e03c6a9e4..048e04a5a332ae7fbd8159b9017b3810e274acd2 100644 (file)
@@ -46,7 +46,7 @@ class Channel_r : public ModeHandler
                }
                else
                {
-                       source->WriteNumeric(500, ":Only a server may modify the +r channel mode");
+                       source->WriteNumeric(500, "Only a server may modify the +r channel mode");
                }
                return MODEACTION_DENY;
        }
@@ -72,7 +72,7 @@ class User_r : public ModeHandler
                }
                else
                {
-                       source->WriteNumeric(500, ":Only a server may modify the +r user mode");
+                       source->WriteNumeric(500, "Only a server may modify the +r user mode");
                }
                return MODEACTION_DENY;
        }
@@ -118,13 +118,17 @@ class AccountExtItemImpl : public AccountExtItem
                User* user = static_cast<User*>(container);
 
                StringExtItem::unserialize(format, container, value);
+
+               // If we are being reloaded then don't send the numeric or run the event
+               if (format == FORMAT_INTERNAL)
+                       return;
+
                if (!value.empty())
                {
                        // Logged in
                        if (IS_LOCAL(user))
                        {
-                               user->WriteNumeric(900, "%s %s :You are now logged in as %s",
-                                       user->GetFullHost().c_str(), value.c_str(), value.c_str());
+                               user->WriteNumeric(900, user->GetFullHost(), value, InspIRCd::Format("You are now logged in as %s", value.c_str()));
                        }
                }
                // If value is empty then logged out
@@ -133,7 +137,7 @@ class AccountExtItemImpl : public AccountExtItem
        }
 };
 
-class ModuleServicesAccount : public Module
+class ModuleServicesAccount : public Module, public Whois::EventListener
 {
        AChannel_R m1;
        AChannel_M m2;
@@ -143,8 +147,10 @@ class ModuleServicesAccount : public Module
        AccountExtItemImpl accountname;
        bool checking_ban;
  public:
-       ModuleServicesAccount() : m1(this), m2(this), m3(this), m4(this), m5(this),
-               accountname(this)
+       ModuleServicesAccount()
+               : Whois::EventListener(this)
+               , m1(this), m2(this), m3(this), m4(this), m5(this)
+               , accountname(this)
                , checking_ban(false)
        {
        }
@@ -195,7 +201,7 @@ class ModuleServicesAccount : public Module
                        if (c->IsModeSet(m2) && !is_registered && res != MOD_RES_ALLOW)
                        {
                                // user messaging a +M channel and is not registered
-                               user->WriteNumeric(477, c->name+" :You need to be identified to a registered account to message this channel");
+                               user->WriteNumeric(477, c->name, "You need to be identified to a registered account to message this channel");
                                return MOD_RES_DENY;
                        }
                }
@@ -206,7 +212,7 @@ class ModuleServicesAccount : public Module
                        if (u->IsModeSet(m3) && !is_registered)
                        {
                                // user messaging a +R user and is not registered
-                               user->WriteNumeric(477, u->nick +" :You need to be identified to a registered account to message this user");
+                               user->WriteNumeric(477, u->nick, "You need to be identified to a registered account to message this user");
                                return MOD_RES_DENY;
                        }
                }
@@ -261,7 +267,7 @@ class ModuleServicesAccount : public Module
                                if (!is_registered)
                                {
                                        // joining a +R channel and not identified
-                                       user->WriteNumeric(477, chan->name + " :You need to be identified to a registered account to join this channel");
+                                       user->WriteNumeric(477, chan->name, "You need to be identified to a registered account to join this channel");
                                        return MOD_RES_DENY;
                                }
                        }