1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 /* $ModDesc: Provides support for unreal-style SAJOIN command */
20 class CommandSajoin : public Command
23 CommandSajoin(Module* Creator) : Command(Creator,"SAJOIN", 2)
25 flags_needed = 'o'; Penalty = 0; syntax = "<nick> <channel>";
26 TRANSLATE3(TR_NICK, TR_TEXT, TR_END);
29 CmdResult Handle (const std::vector<std::string>& parameters, User *user)
31 User* dest = ServerInstance->FindNick(parameters[0]);
34 if (ServerInstance->ULine(dest->server))
36 user->WriteNumeric(ERR_NOPRIVILEGES, "%s :Cannot use an SA command on a u-lined client",user->nick.c_str());
39 if (IS_LOCAL(user) && !ServerInstance->IsChannel(parameters[1].c_str(), ServerInstance->Config->Limits.ChanMax))
41 /* we didn't need to check this for each character ;) */
42 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Invalid characters in channel name or name too long");
46 /* For local users, we send the JoinUser which may create a channel and set its TS.
47 * For non-local users, we just return CMD_SUCCESS, knowing this will propagate it where it needs to be
48 * and then that server will generate the users JOIN or FJOIN instead.
52 Channel::JoinUser(dest, parameters[1].c_str(), true, "", false, ServerInstance->Time());
53 /* Fix for dotslasher and w00t - if the join didnt succeed, return CMD_FAILURE so that it doesnt propagate */
54 Channel* n = ServerInstance->FindChan(parameters[1]);
59 ServerInstance->SNO->WriteToSnoMask('a', std::string(user->nick)+" used SAJOIN to make "+std::string(dest->nick)+" join "+parameters[1]);
64 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Could not join "+std::string(dest->nick)+" to "+parameters[1]+" (User is probably banned, or blocking modes)");
70 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Could not join "+std::string(dest->nick)+" to "+parameters[1]);
76 ServerInstance->SNO->WriteToSnoMask('a', std::string(user->nick)+" sent remote SAJOIN to make "+std::string(dest->nick)+" join "+parameters[1]);
82 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** No such nickname "+parameters[0]);
87 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
89 User* dest = ServerInstance->FindNick(parameters[0]);
91 return ROUTE_OPT_UCAST(dest->server);
92 return ROUTE_LOCALONLY;
96 class ModuleSajoin : public Module
103 ServerInstance->AddCommand(&cmd);
106 virtual ~ModuleSajoin()
110 virtual Version GetVersion()
112 return Version("Provides support for unreal-style SAJOIN command", VF_OPTCOMMON | VF_VENDOR, API_VERSION);
117 MODULE_INIT(ModuleSajoin)