2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2013-2014 Attila Molnar <attilamolnar@hush.com>
5 * Copyright (C) 2013, 2017 Sadie Powell <sadie@witchery.services>
6 * Copyright (C) 2012 Robby <robby@chatbelgie.be>
7 * Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
8 * Copyright (C) 2009 Uli Schlachter <psychon@inspircd.org>
9 * Copyright (C) 2008 Thomas Stagner <aquanight@inspircd.org>
10 * Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
11 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
12 * Copyright (C) 2006, 2010 Craig Edwards <brain@inspircd.org>
14 * This file is part of InspIRCd. InspIRCd is free software: you can
15 * redistribute it and/or modify it under the terms of the GNU General Public
16 * License as published by the Free Software Foundation, version 2.
18 * This program is distributed in the hope that it will be useful, but WITHOUT
19 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
33 /** Description of this snomask, e.g.: OPER, ANNOUNCEMENT, XLINE
35 std::string Description;
37 /** Information about the last sent message,
38 * used for sending "last message repeated X times" messages
40 std::string LastMessage;
44 /** Log and send a message to all opers who have the given snomask set
45 * @param letter The target users of this message
46 * @param desc The description of this snomask, will be prepended to the message
47 * @param msg The message to send
49 static void Send(char letter, const std::string& desc, const std::string& msg);
52 /** Create a new Snomask
56 /** Sends a message to all opers with this snomask.
57 * @param message The message to send
58 * @param letter The snomask character to send the message to.
60 void SendMessage(const std::string& message, char letter);
62 /** Sends out the (last message repeated N times) message
66 /** Returns the description of this snomask
67 * @param letter The letter of this snomask. If uppercase, the description of the remote
68 * variant of this snomask will be returned (i.e.: "REMOTE" will be prepended to the description).
69 * @return The description of this snomask
71 std::string GetDescription(char letter) const;
73 friend class SnomaskManager;
76 /** Snomask manager handles routing of SNOMASK (usermode +s) messages to opers.
77 * Modules and the core can enable and disable snomask characters. If they do,
78 * then sending snomasks using these characters becomes possible.
80 class CoreExport SnomaskManager : public fakederef<SnomaskManager>
85 /** Create a new SnomaskManager
90 * @param letter The snomask letter to enable. Once enabled,
91 * server notices may be routed to users with this letter in
92 * their list, and users may add this letter to their list.
93 * @param description The descriptive text sent along with any
94 * server notices, at the start of the notice, e.g. "GLOBOPS".
96 void EnableSnomask(char letter, const std::string &description);
98 /** Write to all users with a given snomask (local server only)
99 * @param letter The snomask letter to write to
100 * @param text The text to send to the users
102 void WriteToSnoMask(char letter, const std::string &text);
104 /** Write to all users with a given snomask (local server only)
105 * @param letter The snomask letter to write to
106 * @param text A format string containing text to send
107 * @param ... Format arguments
109 void WriteToSnoMask(char letter, const char* text, ...) CUSTOM_PRINTF(3, 4);
111 /** Write to all users with a given snomask (sent globally)
112 * @param letter The snomask letter to write to
113 * @param text The text to send to the users
115 void WriteGlobalSno(char letter, const std::string &text);
117 /** Write to all users with a given snomask (sent globally)
118 * @param letter The snomask letter to write to
119 * @param text A format string containing text to send
120 * @param ... Format arguments
122 void WriteGlobalSno(char letter, const char* text, ...) CUSTOM_PRINTF(3, 4);
124 /** Called once per 5 seconds from the mainloop, this flushes any cached
125 * snotices. The way the caching works is as follows:
126 * Calls to WriteToSnoMask write to a cache, if the call is the same as it was
127 * for the previous call, then a count is incremented. If it is different,
128 * the previous message it just sent normally via NOTICE (with count if > 1)
129 * and the new message is cached. This acts as a sender in case the number of notices
130 * is not particularly significant, in order to keep notices going out.
132 void FlushSnotices();
134 /** Check whether a given character is an enabled (initialized) snomask.
135 * Valid snomask chars are lower- or uppercase letters and have a description.
136 * Snomasks are initialized with EnableSnomask().
137 * @param ch The character to check
138 * @return True if the given char is allowed to be set via +s.
140 bool IsSnomaskUsable(char ch) const;