1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 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 * ---------------------------------------------------
16 /* $ModDesc: Provides support for unreal-style SAJOIN command */
20 class CommandSajoin : public Command
23 CommandSajoin (InspIRCd* Instance) : Command(Instance,"SAJOIN", "o", 2, false, 0)
25 this->source = "m_sajoin.so";
26 syntax = "<nick> <channel>";
27 TRANSLATE3(TR_NICK, TR_TEXT, TR_END);
30 CmdResult Handle (const std::vector<std::string>& parameters, User *user)
32 User* dest = ServerInstance->FindNick(parameters[0]);
35 if (ServerInstance->ULine(dest->server))
37 user->WriteNumeric(ERR_NOPRIVILEGES, "%s :Cannot use an SA command on a u-lined client",user->nick.c_str());
40 if (IS_LOCAL(user) && !ServerInstance->IsChannel(parameters[1].c_str(), ServerInstance->Config->Limits.ChanMax))
42 /* we didn't need to check this for each character ;) */
43 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Invalid characters in channel name or name too long");
47 /* For local users, we send the JoinUser which may create a channel and set its TS.
48 * For non-local users, we just return CMD_SUCCESS, knowing this will propagate it where it needs to be
49 * and then that server will generate the users JOIN or FJOIN instead.
53 Channel::JoinUser(ServerInstance, dest, parameters[1].c_str(), true, "", false, ServerInstance->Time());
54 /* Fix for dotslasher and w00t - if the join didnt succeed, return CMD_FAILURE so that it doesnt propagate */
55 Channel* n = ServerInstance->FindChan(parameters[1]);
60 ServerInstance->SNO->WriteToSnoMask('A', std::string(user->nick)+" used SAJOIN to make "+std::string(dest->nick)+" join "+parameters[1]);
65 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Could not join "+std::string(dest->nick)+" to "+parameters[1]+" (User is probably banned, or blocking modes)");
71 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Could not join "+std::string(dest->nick)+" to "+parameters[1]);
77 ServerInstance->SNO->WriteToSnoMask('A', std::string(user->nick)+" sent remote SAJOIN to make "+std::string(dest->nick)+" join "+parameters[1]);
83 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** No such nickname "+parameters[0]);
89 class ModuleSajoin : public Module
91 CommandSajoin* mycommand;
93 ModuleSajoin(InspIRCd* Me)
97 mycommand = new CommandSajoin(ServerInstance);
98 ServerInstance->AddCommand(mycommand);
102 virtual ~ModuleSajoin()
106 virtual Version GetVersion()
108 return Version(1, 2, 0, 1, VF_COMMON | VF_VENDOR, API_VERSION);
113 MODULE_INIT(ModuleSajoin)