1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
19 /* $ModDesc: Provides support for unreal-style SAJOIN command */
23 class cmd_sajoin : public command_t
26 cmd_sajoin (InspIRCd* Instance) : command_t(Instance,"SAJOIN", 'o', 2)
28 this->source = "m_sajoin.so";
29 syntax = "<nick> <channel>";
32 CmdResult Handle (const char** parameters, int pcnt, userrec *user)
34 userrec* dest = ServerInstance->FindNick(parameters[0]);
37 if (ServerInstance->ULine(dest->server))
39 user->WriteServ("990 %s :Cannot use an SA command on a u-lined client",user->nick);
42 if (!ServerInstance->IsChannel(parameters[1]))
44 /* we didn't need to check this for each character ;) */
45 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Invalid characters in channel name");
49 /* For local users, we send the JoinUser which may create a channel and set its TS.
50 * For non-local users, we just return CMD_SUCCESS, knowing this will propogate it where it needs to be
51 * and then that server will generate the users JOIN or FJOIN instead.
55 chanrec::JoinUser(ServerInstance, dest, parameters[1], true, "", ServerInstance->Time(true));
56 /* Fix for dotslasher and w00t - if the join didnt succeed, return CMD_FAILURE so that it doesnt propogate */
57 chanrec* n = ServerInstance->FindChan(parameters[1]);
62 ServerInstance->WriteOpers("*** "+std::string(user->nick)+" used SAJOIN to make "+std::string(dest->nick)+" join "+parameters[1]);
67 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Could not join "+std::string(dest->nick)+" to "+parameters[1]+" (User is probably banned, or blocking modes)");
73 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Could not join "+std::string(dest->nick)+" to "+parameters[1]);
79 ServerInstance->WriteOpers("*** "+std::string(user->nick)+" sent remote SAJOIN to make "+std::string(dest->nick)+" join "+parameters[1]);
85 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** No such nickname "+parameters[0]);
91 class ModuleSajoin : public Module
93 cmd_sajoin* mycommand;
95 ModuleSajoin(InspIRCd* Me)
99 mycommand = new cmd_sajoin(ServerInstance);
100 ServerInstance->AddCommand(mycommand);
103 virtual ~ModuleSajoin()
107 virtual Version GetVersion()
109 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
114 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
116 class ModuleSajoinFactory : public ModuleFactory
119 ModuleSajoinFactory()
123 ~ModuleSajoinFactory()
127 virtual Module * CreateModule(InspIRCd* Me)
129 return new ModuleSajoin(Me);
135 extern "C" DllExport void * init_module( void )
137 return new ModuleSajoinFactory;