]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_satopic.cpp
67756158a0a0cdf48a4fa74c2caf9b1244194564
[user/henk/code/inspircd.git] / src / modules / m_satopic.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/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, 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                         return CMD_LOCALONLY;
47                 }
48                 else
49                 {
50                         user->WriteNumeric(401, "%s %s :No such nick/channel", user->nick.c_str(), parameters[0].c_str());
51                         return CMD_FAILURE;
52                 }
53         }
54 };
55
56 class ModuleSATopic : public Module
57 {
58         CommandSATopic* mycommand;
59  public:
60         ModuleSATopic(InspIRCd* Me)
61         : Module(Me)
62         {
63                 mycommand = new CommandSATopic(ServerInstance);
64                 ServerInstance->AddCommand(mycommand);
65         }
66
67         virtual ~ModuleSATopic()
68         {
69         }
70
71         virtual Version GetVersion()
72         {
73                 return Version("$Id$", VF_VENDOR, API_VERSION);
74         }
75 };
76
77 MODULE_INIT(ModuleSATopic)