]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_satopic.cpp
Initial commit of m_satopic, provides /satopic. Needs testing on a multi-server network.
[user/henk/code/inspircd.git] / src / modules / m_satopic.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 /* $ModDesc: Provides a SATOPIC command */
15
16 #include "inspircd.h"
17
18 /** Handle /SATOPIC
19  */
20 class CommandSATopic : public Command
21 {
22  public:
23         CommandSATopic (InspIRCd* Instance)
24         : Command(Instance,"SATOPIC", "o", 2, false, 0)
25         {
26                 this->source = "m_satopic.so";
27                 syntax = "<target> <topic>";
28         }
29
30         CmdResult Handle (const std::vector<std::string>& parameters, User *user)
31         {
32                 /*
33                  * Handles a SATOPIC request. Notifies all +s users.
34                  */
35                 Channel* target = ServerInstance->FindChan(parameters[0]);
36
37                 if(target)
38                 {
39                         std::string newTopic = parameters[1];
40                         
41                         // 3rd parameter overrides access checks
42                         target->SetTopic(user, newTopic, true);
43                         ServerInstance->SNO->WriteToSnoMask('A', user->nick + " used SATOPIC on " + target->name + ", new topic: " + newTopic);
44
45                         /* I think this is right, the TOPIC message generated should be
46                          * propogated without the SATOPIC command itself having to be.
47                          */
48                         return CMD_LOCALONLY;
49                 }
50                 else
51                 {
52                         user->WriteNumeric(401, "%s %s :No such nick/channel", user->nick.c_str(), target->name.c_str());
53                         return CMD_FAILURE;
54                 }
55         }
56 };
57
58 class ModuleSATopic : public Module
59 {
60         CommandSATopic* mycommand;
61  public:
62         ModuleSATopic(InspIRCd* Me)
63         : Module(Me)
64         {
65                 mycommand = new CommandSATopic(ServerInstance);
66                 ServerInstance->AddCommand(mycommand);
67         }
68
69         virtual ~ModuleSATopic()
70         {
71         }
72
73         virtual Version GetVersion()
74         {
75                 return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
76         }
77 };
78
79 MODULE_INIT(ModuleSATopic)