]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_sajoin.cpp
Added a parameter to OnRehash for the rehash parameter
[user/henk/code/inspircd.git] / src / modules / m_sajoin.cpp
index 5e7ae97868eb9a7f950cf175859fb1cea6319fca..f82bba20335b7af9807745415b6b2d7ef32c1ab2 100644 (file)
@@ -1,4 +1,20 @@
-// Sajoin and +g support module by C.J.Edwards
+/*       +------------------------------------+
+ *       | Inspire Internet Relay Chat Daemon |
+ *       +------------------------------------+
+ *
+ *  Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
+ *                       E-mail:
+ *                <brain@chatspike.net>
+ *               <Craig@chatspike.net>
+ *     
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ *            the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
 
 #include <stdio.h>
 #include <string>
@@ -6,7 +22,7 @@
 #include "channels.h"
 #include "modules.h"
 
-/* $ModDesc: Provides support for unreal-style GLOBOPS and umode +g */
+/* $ModDesc: Provides support for unreal-style SAJOIN command */
 
 Server *Srv;
         
@@ -15,8 +31,25 @@ void handle_sajoin(char **parameters, int pcnt, userrec *user)
        userrec* dest = Srv->FindNick(std::string(parameters[0]));
        if (dest)
        {
-               Srv->SendOpers(std::string(user->nick)+" used SAJOIN to make "+std::String(dest->nick)+" join "+parameters[1]);
-               Srv->JoinUserToChannel(dest,std::String(parameters[1]),std::string(dest->nick));
+               /* might be nicer to make checking valid channel names an api function sometime --w00t */
+               if (parameters[1][0] != '#')
+               {
+                       /* we didn't need to check this for each character ;) */
+                       Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in channel name");
+                       return;
+               }
+
+               for (unsigned int x = 0; x < strlen(parameters[1]); x++)
+               {
+                               if ((parameters[1][x] == ' ') || (parameters[1][x] == ','))
+                               {
+                                       Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in channel name");
+                                       return;
+                               }
+               }
+
+               Srv->SendOpers(std::string(user->nick)+" used SAJOIN to make "+std::string(dest->nick)+" join "+parameters[1]);
+               Srv->JoinUserToChannel(dest,std::string(parameters[1]),std::string(dest->nick));
        }
 }
 
@@ -27,7 +60,7 @@ class ModuleSajoin : public Module
        ModuleSajoin()
        {
                Srv = new Server;
-               Srv->AddCommand("SAJOIN",handle_sajoin,'o',2);
+               Srv->AddCommand("SAJOIN",handle_sajoin,'o',2,"m_sajoin.so");
        }
        
        virtual ~ModuleSajoin()
@@ -37,7 +70,7 @@ class ModuleSajoin : public Module
        
        virtual Version GetVersion()
        {
-               return Version(1,0,0,1);
+               return Version(1,0,0,1,VF_VENDOR);
        }
        
 };