2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2019 Peter Powell <petpow@saberuk.com>
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.
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
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/>.
19 // IMPORTANT: The contents of this file are experimental and are not presently
20 // covered by the InspIRCd API stability guarantee.
25 #include "modules/cap.h"
38 /** Base class for standard replies. */
39 class IRCv3::Replies::Reply
42 /** The name of the command for this reply. */
45 /** The event provider for this reply. */
46 ClientProtocol::EventProvider evprov;
49 /** Initializes a new instance of the Reply class.
50 * @param Creator The module which created this instance.
51 * @param Cmd The name of the command to reply with.
53 Reply(Module* Creator, const std::string& Cmd)
55 , evprov(Creator, Cmd)
61 * Sends a standard reply to the specified user.
62 * @param user The user to send the reply to.
63 * @param command The command that the reply relates to.
64 * @param code A machine readable code for this reply.
65 * @param description A human readable description of this reply.
67 void Send(LocalUser* user, Command* command, const std::string& code, const std::string& description)
69 ClientProtocol::Message msg(cmd.c_str(), ServerInstance->Config->ServerName);
70 msg.PushParamRef(command->name);
72 msg.PushParam(description);
74 ClientProtocol::Event ev(evprov, msg);
79 * Sends a standard reply to the specified user if they have the specified cap
80 * or a notice if they do not.s
81 * @param user The user to send the reply to.
82 * @param command The command that the reply relates to.
83 * @param code A machine readable code for this reply.
84 * @param description A human readable description of this reply.
86 void SendIfCap(LocalUser* user, const Cap::Capability& cap, Command* command, const std::string& code, const std::string& description)
89 Send(user, command, code, description);
91 user->WriteNotice(InspIRCd::Format("*** %s: %s", command->name.c_str(), description.c_str()));
95 /** Sends a FAIL standard reply. */
96 class IRCv3::Replies::Fail
97 : public IRCv3::Replies::Reply
100 /** Initializes a new instance of the Fail class.
101 * @param Creator The module which created this instance.
103 Fail(Module* Creator)
104 : Reply(Creator, "FAIL")
109 /** Sends a NOTE standard reply. */
110 class IRCv3::Replies::Note
111 : public IRCv3::Replies::Reply
114 /** Initializes a new instance of the Note class.
115 * @param Creator The module which created this instance.
117 Note(Module* Creator)
118 : Reply(Creator, "NOTE")
123 /** Sends a WARN standard reply. */
124 class IRCv3::Replies::Warn
125 : public IRCv3::Replies::Reply
128 /** Initializes a new instance of the Warn class.
129 * @param Creator The module which created this instance.
131 Warn(Module* Creator)
132 : Reply(Creator, "WARN")