2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2010 Daniel De Graaf <danieldg@inspircd.org>
5 * Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
6 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
7 * Copyright (C) 2006 Craig Edwards <craigedwards@brainbox.cc>
9 * This file is part of InspIRCd. InspIRCd is free software: you can
10 * redistribute it and/or modify it under the terms of the GNU General Public
11 * License as published by the Free Software Foundation, version 2.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28 /** Description of this snomask, e.g.: OPER, ANNOUNCEMENT, XLINE
30 std::string Description;
32 /** Information about the last sent message,
33 * used for sending "last message repeated X times" messages
35 std::string LastMessage;
39 /** Log and send a message to all opers who have the given snomask set
40 * @param letter The target users of this message
41 * @param desc The description of this snomask, will be prepended to the message
42 * @param msg The message to send
44 static void Send(char letter, const std::string& desc, const std::string& msg);
47 /** Create a new Snomask
51 /** Sends a message to all opers with this snomask.
52 * @param message The message to send
53 * @param letter The snomask character to send the message to.
55 void SendMessage(const std::string& message, char letter);
57 /** Sends out the (last message repeated N times) message
61 /** Returns the description of this snomask
62 * @param letter The letter of this snomask. If uppercase, the description of the remote
63 * variant of this snomask will be returned (i.e.: "REMOTE" will be prepended to the description).
64 * @return The description of this snomask
66 std::string GetDescription(char letter) const;
68 friend class SnomaskManager;
71 /** Snomask manager handles routing of SNOMASK (usermode +s) messages to opers.
72 * Modules and the core can enable and disable snomask characters. If they do,
73 * then sending snomasks using these characters becomes possible.
75 class CoreExport SnomaskManager : public fakederef<SnomaskManager>
80 /** Create a new SnomaskManager
85 * @param letter The snomask letter to enable. Once enabled,
86 * server notices may be routed to users with this letter in
87 * their list, and users may add this letter to their list.
88 * @param description The descriptive text sent along with any
89 * server notices, at the start of the notice, e.g. "GLOBOPS".
91 void EnableSnomask(char letter, const std::string &description);
93 /** Write to all users with a given snomask (local server only)
94 * @param letter The snomask letter to write to
95 * @param text The text to send to the users
97 void WriteToSnoMask(char letter, const std::string &text);
99 /** Write to all users with a given snomask (local server only)
100 * @param letter The snomask letter to write to
101 * @param text A format string containing text to send
102 * @param ... Format arguments
104 void WriteToSnoMask(char letter, const char* text, ...) CUSTOM_PRINTF(3, 4);
106 /** Write to all users with a given snomask (sent globally)
107 * @param letter The snomask letter to write to
108 * @param text The text to send to the users
110 void WriteGlobalSno(char letter, const std::string &text);
112 /** Write to all users with a given snomask (sent globally)
113 * @param letter The snomask letter to write to
114 * @param text A format string containing text to send
115 * @param ... Format arguments
117 void WriteGlobalSno(char letter, const char* text, ...) CUSTOM_PRINTF(3, 4);
119 /** Called once per 5 seconds from the mainloop, this flushes any cached
120 * snotices. The way the caching works is as follows:
121 * Calls to WriteToSnoMask write to a cache, if the call is the same as it was
122 * for the previous call, then a count is incremented. If it is different,
123 * the previous message it just sent normally via NOTICE (with count if > 1)
124 * and the new message is cached. This acts as a sender in case the number of notices
125 * is not particularly significant, in order to keep notices going out.
127 void FlushSnotices();
129 /** Check whether a given character is an enabled (initialized) snomask.
130 * Valid snomask chars are lower- or uppercase letters and have a description.
131 * Snomasks are initialized with EnableSnomask().
132 * @param ch The character to check
133 * @return True if the given char is allowed to be set via +s.
135 bool IsSnomaskUsable(char ch) const;