]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_sajoin.cpp
A ton more clear() and empty() stuff thats been lingering on the long term todo for...
[user/henk/code/inspircd.git] / src / modules / m_sajoin.cpp
index 494d255dfabb24f9e7ef5a5aad3806002d2b3a4d..29abc0ba9347352e53fb8756ff180b164ed8f2e0 100644 (file)
@@ -2,28 +2,20 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
- *                    E-mail:
- *             <brain@chatspike.net>
- *               <Craig@chatspike.net>
- *     
- * Written by Craig Edwards, Craig McLure, and others.
+ *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
+ *
  * This program is free but copyrighted software; see
- *         the file COPYING for details.
+ *            the file COPYING for details.
  *
  * ---------------------------------------------------
  */
 
-using namespace std;
-
-#include <stdio.h>
-#include <string>
+#include "inspircd.h"
 #include "users.h"
 #include "channels.h"
 #include "modules.h"
 
-#include "inspircd.h"
-
 /* $ModDesc: Provides support for unreal-style SAJOIN command */
 
 /** Handle /SAJOIN
@@ -54,31 +46,45 @@ class cmd_sajoin : public command_t
                                return CMD_FAILURE;
                        }
 
-                       chanrec::JoinUser(ServerInstance, dest, parameters[1], true);
-
-                       /* Fix for dotslasher and w00t - if the join didnt succeed, return CMD_FAILURE so that it doesnt propogate */
-                       chanrec* n = ServerInstance->FindChan(parameters[1]);
-                       if (n)
+                       /* For local users, we send the JoinUser which may create a channel and set its TS.
+                        * For non-local users, we just return CMD_SUCCESS, knowing this will propogate it where it needs to be
+                        * and then that server will generate the users JOIN or FJOIN instead.
+                        */
+                       if (IS_LOCAL(dest))
                        {
-                               if (n->HasUser(dest))
+                               chanrec::JoinUser(ServerInstance, dest, parameters[1], true, "", ServerInstance->Time(true));
+                               /* Fix for dotslasher and w00t - if the join didnt succeed, return CMD_FAILURE so that it doesnt propogate */
+                               chanrec* n = ServerInstance->FindChan(parameters[1]);
+                               if (n)
                                {
-                                       ServerInstance->WriteOpers(std::string(user->nick)+" used SAJOIN to make "+std::string(dest->nick)+" join "+parameters[1]);
-                                       return CMD_SUCCESS;
+                                       if (n->HasUser(dest))
+                                       {
+                                               ServerInstance->WriteOpers("*** "+std::string(user->nick)+" used SAJOIN to make "+std::string(dest->nick)+" join "+parameters[1]);
+                                               return CMD_SUCCESS;
+                                       }
+                                       else
+                                       {
+                                               user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Could not join "+std::string(dest->nick)+" to "+parameters[1]+" (User is probably banned, or blocking modes)");
+                                               return CMD_FAILURE;
+                                       }
                                }
                                else
                                {
-                                       user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Could not join "+std::string(dest->nick)+" to "+parameters[1]+" (User is probably banned, or blocking modes)");
+                                       user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Could not join "+std::string(dest->nick)+" to "+parameters[1]);
                                        return CMD_FAILURE;
                                }
                        }
                        else
                        {
-                               user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Could not join "+std::string(dest->nick)+" to "+parameters[1]);
-                               return CMD_FAILURE;
+                               ServerInstance->WriteOpers("*** "+std::string(user->nick)+" sent remote SAJOIN to make "+std::string(dest->nick)+" join "+parameters[1]);
+                               return CMD_SUCCESS;
                        }
                }
-
-               return CMD_SUCCESS;
+               else
+               {
+                       user->WriteServ("NOTICE "+std::string(user->nick)+" :*** No such nickname "+parameters[0]);
+                       return CMD_FAILURE;
+               }
        }
 };
 
@@ -87,7 +93,7 @@ class ModuleSajoin : public Module
        cmd_sajoin*     mycommand;
  public:
        ModuleSajoin(InspIRCd* Me)
-               : Module::Module(Me)
+               : Module(Me)
        {
                
                mycommand = new cmd_sajoin(ServerInstance);
@@ -126,7 +132,7 @@ class ModuleSajoinFactory : public ModuleFactory
 };
 
 
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
 {
        return new ModuleSajoinFactory;
 }