]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_satopic.cpp
Add support for blocking tag messages with the deaf mode.
[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, 2020 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';
37                 syntax = "<channel> :<topic>";
38         }
39
40         CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
41         {
42                 /*
43                  * Handles a SATOPIC request. Notifies all +s users.
44                  */
45                 Channel* target = ServerInstance->FindChan(parameters[0]);
46
47                 if(target)
48                 {
49                         const std::string newTopic(parameters[1], 0, ServerInstance->Config->Limits.MaxTopic);
50                         if (target->topic == newTopic)
51                         {
52                                 user->WriteNotice(InspIRCd::Format("The topic on %s is already what you are trying to change it to.", target->name.c_str()));
53                                 return CMD_SUCCESS;
54                         }
55
56                         target->SetTopic(user, newTopic, ServerInstance->Time(), NULL);
57                         ServerInstance->SNO->WriteGlobalSno('a', user->nick + " used SATOPIC on " + target->name + ", new topic: " + newTopic);
58
59                         return CMD_SUCCESS;
60                 }
61                 else
62                 {
63                         user->WriteNumeric(Numerics::NoSuchChannel(parameters[0]));
64                         return CMD_FAILURE;
65                 }
66         }
67 };
68
69 class ModuleSATopic : public Module
70 {
71         CommandSATopic cmd;
72  public:
73         ModuleSATopic()
74         : cmd(this)
75         {
76         }
77
78         Version GetVersion() CXX11_OVERRIDE
79         {
80                 return Version("Adds the /SATOPIC command which allows server operators to change the topic of a channel that they would not otherwise have the privileges to change.", VF_VENDOR);
81         }
82 };
83
84 MODULE_INIT(ModuleSATopic)