]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_satopic.cpp
Fix bug #584 (not with the provided patch) and stuff nobody really cares about
[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                         ServerInstance->PI->SendSNONotice("A", user->nick + " used SATOPIC on " + target->name + ", new topic: " + newTopic);
45
46                         /* I think this is right, the TOPIC message generated should be
47                          * propogated without the SATOPIC command itself having to be.
48                          */
49                         return CMD_LOCALONLY;
50                 }
51                 else
52                 {
53                         user->WriteNumeric(401, "%s %s :No such nick/channel", user->nick.c_str(), target->name.c_str());
54                         return CMD_FAILURE;
55                 }
56         }
57 };
58
59 class ModuleSATopic : public Module
60 {
61         CommandSATopic* mycommand;
62  public:
63         ModuleSATopic(InspIRCd* Me)
64         : Module(Me)
65         {
66                 mycommand = new CommandSATopic(ServerInstance);
67                 ServerInstance->AddCommand(mycommand);
68         }
69
70         virtual ~ModuleSATopic()
71         {
72         }
73
74         virtual Version GetVersion()
75         {
76                 return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
77         }
78 };
79
80 MODULE_INIT(ModuleSATopic)