]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_auditorium.cpp
Fix potential for duplicate SID if the SID is auto generated.
[user/henk/code/inspircd.git] / src / modules / m_auditorium.cpp
index 8bab76b4958117ef1509996703cfdd7dfc582417..de54a22bb59422264860cf827dda43c86d6171ca 100644 (file)
@@ -11,9 +11,6 @@
  * ---------------------------------------------------
  */
 
-#include "users.h"
-#include "channels.h"
-#include "modules.h"
 #include "inspircd.h"
 
 /* $ModDesc: Allows for auditorium channels (+u) where nobody can see others joining and parting or the nick list */
@@ -54,7 +51,7 @@ class ModuleAuditorium : public Module
        CUList except_list;
  public:
        ModuleAuditorium(InspIRCd* Me)
-               : Module::Module(Me)
+               : Module(Me)
        {
                aum = new AuditoriumMode(ServerInstance);
                if (!ServerInstance->AddMode(aum, 'u'))
@@ -96,9 +93,18 @@ class ModuleAuditorium : public Module
                {
                        if (ShowOps)
                        {
+                               /* Leave the names list alone, theyre an op
+                                * doing /names on the channel after joining it
+                                */
+                               if (Ptr->GetStatus(user) >= STATUS_OP)
+                               {
+                                       nameslist = Ptr->GetUsers();
+                                       return 0;
+                               }
+
                                /* Show all the opped users */
                                nl = *(Ptr->GetOppedUsers());
-                               nl[user] = user;
+                               nl[user] = user->nick;
                                nameslist = &nl;
                                return 0;
                        }
@@ -121,7 +127,7 @@ class ModuleAuditorium : public Module
                        /* Because we silenced the event, make sure it reaches the user whos joining (but only them of course) */
                        user->WriteFrom(user, "JOIN %s", channel->name);
                        if (ShowOps)
-                               channel->WriteAllExcept(user, false, '@', except_list, "JOIN %s", channel->name);
+                               channel->WriteAllExcept(user, false, channel->GetStatus(user) >= STATUS_OP ? 0 : '@', except_list, "JOIN %s", channel->name);
                }
        }
 
@@ -135,8 +141,10 @@ class ModuleAuditorium : public Module
                                        partmessage.empty() ? "" : " :",
                                        partmessage.empty() ? "" : partmessage.c_str());
                        if (ShowOps)
-                               channel->WriteAllExcept(user, false, '@', except_list, "PART %s%s%s", channel->name, partmessage.empty() ? "" : " :",
+                       {
+                               channel->WriteAllExcept(user, false, channel->GetStatus(user) >= STATUS_OP ? 0 : '@', except_list, "PART %s%s%s", channel->name, partmessage.empty() ? "" : " :",
                                                partmessage.empty() ? "" : partmessage.c_str());
+                       }
                }
        }
 
@@ -148,7 +156,7 @@ class ModuleAuditorium : public Module
                        /* Send silenced event only to the user being kicked and the user doing the kick */
                        source->WriteFrom(source, "KICK %s %s %s", chan->name, user->nick, reason.c_str());
                        if (ShowOps)
-                               chan->WriteAllExcept(source, false, '@', except_list, "KICK %s %s %s", chan->name, user->nick, reason.c_str());
+                               chan->WriteAllExcept(source, false, chan->GetStatus(source) >= STATUS_OP ? 0 : '@', except_list, "KICK %s %s %s", chan->name, user->nick, reason.c_str());
                        else
                                user->WriteFrom(source, "KICK %s %s %s", chan->name, user->nick, reason.c_str());
                }
@@ -177,26 +185,4 @@ class ModuleAuditorium : public Module
        }
 };
 
-class ModuleAuditoriumFactory : public ModuleFactory
-{
- public:
-       ModuleAuditoriumFactory()
-       {
-       }
-       
-       ~ModuleAuditoriumFactory()
-       {
-       }
-       
-       virtual Module * CreateModule(InspIRCd* Me)
-       {
-               return new ModuleAuditorium(Me);
-       }
-       
-};
-
-extern "C" void * init_module( void )
-{
-       return new ModuleAuditoriumFactory;
-}
-
+MODULE_INIT(ModuleAuditorium)