]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_satopic.cpp
Fix being able to see the modes of private/secret channels.
[user/henk/code/inspircd.git] / src / modules / m_satopic.cpp
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2017 B00mX0r <b00mx0r@aureus.pw>
5  *   Copyright (C) 2013, 2018 Sadie Powell <sadie@witchery.services>
6  *   Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
7  *   Copyright (C) 2012, 2016 Attila Molnar <attilamolnar@hush.com>
8  *   Copyright (C) 2009 Uli Schlachter <psychon@inspircd.org>
9  *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
10  *   Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
11  *   Copyright (C) 2008 Oliver Lupton <om@inspircd.org>
12  *
13  * This file is part of InspIRCd.  InspIRCd is free software: you can
14  * redistribute it and/or modify it under the terms of the GNU General Public
15  * License as published by the Free Software Foundation, version 2.
16  *
17  * This program is distributed in the hope that it will be useful, but WITHOUT
18  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
20  * details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
24  */
25
26
27 #include "inspircd.h"
28
29 /** Handle /SATOPIC
30  */
31 class CommandSATopic : public Command
32 {
33  public:
34         CommandSATopic(Module* Creator) : Command(Creator,"SATOPIC", 2, 2)
35         {
36                 flags_needed = 'o'; syntax = "<channel> :<topic>";
37         }
38
39         CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
40         {
41                 /*
42                  * Handles a SATOPIC request. Notifies all +s users.
43                  */
44                 Channel* target = ServerInstance->FindChan(parameters[0]);
45
46                 if(target)
47                 {
48                         const std::string newTopic(parameters[1], 0, ServerInstance->Config->Limits.MaxTopic);
49                         if (target->topic == newTopic)
50                         {
51                                 user->WriteNotice(InspIRCd::Format("The topic on %s is already what you are trying to change it to.", target->name.c_str()));
52                                 return CMD_SUCCESS;
53                         }
54
55                         target->SetTopic(user, newTopic, ServerInstance->Time(), NULL);
56                         ServerInstance->SNO->WriteGlobalSno('a', user->nick + " used SATOPIC on " + target->name + ", new topic: " + newTopic);
57
58                         return CMD_SUCCESS;
59                 }
60                 else
61                 {
62                         user->WriteNumeric(Numerics::NoSuchChannel(parameters[0]));
63                         return CMD_FAILURE;
64                 }
65         }
66 };
67
68 class ModuleSATopic : public Module
69 {
70         CommandSATopic cmd;
71  public:
72         ModuleSATopic()
73         : cmd(this)
74         {
75         }
76
77         Version GetVersion() CXX11_OVERRIDE
78         {
79                 return Version("Provides the SATOPIC command", VF_VENDOR);
80         }
81 };
82
83 MODULE_INIT(ModuleSATopic)