]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_services_account.cpp
Allow Timers to delete themselves in Tick()
[user/henk/code/inspircd.git] / src / modules / m_services_account.cpp
index 5f288424ca685bc0c008452b404b0f695ce694f1..feb62f8582169a9825679aa873577082a92ac6aa 100644 (file)
@@ -102,6 +102,24 @@ class AChannel_M : public SimpleChannelModeHandler
        AChannel_M(Module* Creator) : SimpleChannelModeHandler(Creator, "regmoderated", 'M') { }
 };
 
+static bool ReadCGIIRCExt(const char* extname, User* user, const std::string*& out)
+{
+       ExtensionItem* wiext = ServerInstance->Extensions.GetItem(extname);
+       if (!wiext)
+               return false;
+
+       if (wiext->creator->ModuleSourceFile != "m_cgiirc.so")
+               return false;
+
+       StringExtItem* stringext = static_cast<StringExtItem*>(wiext);
+       std::string* addr = stringext->get(user);
+       if (!addr)
+               return false;
+
+       out = addr;
+       return true;
+}
+
 class AccountExtItemImpl : public AccountExtItem
 {
  public:
@@ -121,8 +139,19 @@ class AccountExtItemImpl : public AccountExtItem
                {
                        // 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());
+                       {
+                               const std::string* host = &user->dhost;
+                               if (user->registered != REG_ALL)
+                               {
+                                       if (!ReadCGIIRCExt("cgiirc_webirc_hostname", user, host))
+                                       {
+                                               ReadCGIIRCExt("cgiirc_webirc_ip", user, host);
+                                       }
+                               }
+
+                               user->WriteNumeric(900, "%s!%s@%s %s :You are now logged in as %s",
+                                       user->nick.c_str(), user->ident.c_str(), host->c_str(), value.c_str(), value.c_str());
+                       }
 
                        AccountEvent(creator, user, value).Send();
                }
@@ -142,6 +171,7 @@ class ModuleServicesAccount : public Module
        Channel_r m4;
        User_r m5;
        AccountExtItemImpl accountname;
+       bool checking_ban;
  public:
        ModuleServicesAccount() : m1(this), m2(this), m3(this), m4(this), m5(this),
                accountname(this)
@@ -219,8 +249,7 @@ class ModuleServicesAccount : public Module
 
        ModResult OnCheckBan(User* user, Channel* chan, const std::string& mask) CXX11_OVERRIDE
        {
-               static bool checking = false;
-               if (checking)
+               if (checking_ban)
                        return MOD_RES_PASSTHRU;
 
                if ((mask.length() > 2) && (mask[1] == ':'))
@@ -240,9 +269,9 @@ class ModuleServicesAccount : public Module
 
                                /* If we made it this far we know the user isn't registered
                                        so just deny if it matches */
-                               checking = true;
+                               checking_ban = true;
                                bool result = chan->CheckBan(user, mask.substr(2));
-                               checking = false;
+                               checking_ban = false;
 
                                if (result)
                                        return MOD_RES_DENY;
@@ -288,4 +317,3 @@ class ModuleServicesAccount : public Module
 };
 
 MODULE_INIT(ModuleServicesAccount)
-