]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_satopic.cpp
m_satopic Use WriteGlobalSno instead of writing the same thing with SNO->WriteToSnoMa...
[user/henk/code/inspircd.git] / src / modules / m_satopic.cpp
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2008 Oliver Lupton <oliverlupton@gmail.com>
5  *
6  * This file is part of InspIRCd.  InspIRCd is free software: you can
7  * redistribute it and/or modify it under the terms of the GNU General Public
8  * License as published by the Free Software Foundation, version 2.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18
19
20 /* $ModDesc: Provides a SATOPIC command */
21
22 #include "inspircd.h"
23
24 /** Handle /SATOPIC
25  */
26 class CommandSATopic : public Command
27 {
28  public:
29         CommandSATopic(Module* Creator) : Command(Creator,"SATOPIC", 2, 2)
30         {
31                 flags_needed = 'o'; Penalty = 0; syntax = "<target> <topic>";
32         }
33
34         CmdResult Handle (const std::vector<std::string>& parameters, User *user)
35         {
36                 /*
37                  * Handles a SATOPIC request. Notifies all +s users.
38                  */
39                 Channel* target = ServerInstance->FindChan(parameters[0]);
40
41                 if(target)
42                 {
43                         std::string newTopic = parameters[1];
44
45                         // 3rd parameter overrides access checks
46                         target->SetTopic(user, newTopic, true);
47                         ServerInstance->SNO->WriteGlobalSno('a', user->nick + " used SATOPIC on " + target->name + ", new topic: " + newTopic);
48
49                         return CMD_SUCCESS;
50                 }
51                 else
52                 {
53                         user->WriteNumeric(401, "%s %s :No such nick/channel", user->nick.c_str(), parameters[0].c_str());
54                         return CMD_FAILURE;
55                 }
56         }
57 };
58
59 class ModuleSATopic : public Module
60 {
61         CommandSATopic cmd;
62  public:
63         ModuleSATopic()
64         : cmd(this)
65         {
66                 ServerInstance->AddCommand(&cmd);
67         }
68
69         virtual ~ModuleSATopic()
70         {
71         }
72
73         virtual Version GetVersion()
74         {
75                 return Version("Provides a SATOPIC command", VF_VENDOR);
76         }
77 };
78
79 MODULE_INIT(ModuleSATopic)