]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_sajoin.cpp
Finally change all the Version() objects
[user/henk/code/inspircd.git] / src / modules / m_sajoin.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15
16 /* $ModDesc: Provides support for unreal-style SAJOIN command */
17
18 /** Handle /SAJOIN
19  */
20 class CommandSajoin : public Command
21 {
22  public:
23         CommandSajoin (InspIRCd* Instance) : Command(Instance,"SAJOIN", "o", 2, false, 0)
24         {
25                 this->source = "m_sajoin.so";
26                 syntax = "<nick> <channel>";
27                 TRANSLATE3(TR_NICK, TR_TEXT, TR_END);
28         }
29
30         CmdResult Handle (const char* const* parameters, int pcnt, User *user)
31         {
32                 User* dest = ServerInstance->FindNick(parameters[0]);
33                 if (dest)
34                 {
35                         if (ServerInstance->ULine(dest->server))
36                         {
37                                 user->WriteNumeric(990, "%s :Cannot use an SA command on a u-lined client",user->nick);
38                                 return CMD_FAILURE;
39                         }
40                         if (!ServerInstance->IsChannel(parameters[1]))
41                         {
42                                 /* we didn't need to check this for each character ;) */
43                                 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Invalid characters in channel name");
44                                 return CMD_FAILURE;
45                         }
46
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.
50                          */
51                         if (IS_LOCAL(dest))
52                         {
53                                 Channel::JoinUser(ServerInstance, dest, parameters[1], 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]);
56                                 if (n)
57                                 {
58                                         if (n->HasUser(dest))
59                                         {
60                                                 ServerInstance->SNO->WriteToSnoMask('A', std::string(user->nick)+" used SAJOIN to make "+std::string(dest->nick)+" join "+parameters[1]);
61                                                 return CMD_SUCCESS;
62                                         }
63                                         else
64                                         {
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)");
66                                                 return CMD_FAILURE;
67                                         }
68                                 }
69                                 else
70                                 {
71                                         user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Could not join "+std::string(dest->nick)+" to "+parameters[1]);
72                                         return CMD_FAILURE;
73                                 }
74                         }
75                         else
76                         {
77                                 ServerInstance->SNO->WriteToSnoMask('A', std::string(user->nick)+" sent remote SAJOIN to make "+std::string(dest->nick)+" join "+parameters[1]);
78                                 return CMD_SUCCESS;
79                         }
80                 }
81                 else
82                 {
83                         user->WriteServ("NOTICE "+std::string(user->nick)+" :*** No such nickname "+parameters[0]);
84                         return CMD_FAILURE;
85                 }
86         }
87 };
88
89 class ModuleSajoin : public Module
90 {
91         CommandSajoin*  mycommand;
92  public:
93         ModuleSajoin(InspIRCd* Me)
94                 : Module(Me)
95         {
96                 
97                 mycommand = new CommandSajoin(ServerInstance);
98                 ServerInstance->AddCommand(mycommand);
99
100         }
101         
102         virtual ~ModuleSajoin()
103         {
104         }
105         
106         virtual Version GetVersion()
107         {
108                 return Version(1, 2, 0, 1, VF_COMMON | VF_VENDOR, API_VERSION);
109         }
110         
111 };
112
113 MODULE_INIT(ModuleSajoin)