]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/snomasks.h
Tidy up source files:
[user/henk/code/inspircd.git] / include / snomasks.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
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>
8  *
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.
12  *
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
16  * details.
17  *
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/>.
20  */
21
22
23 #pragma once
24
25 class Snomask
26 {
27  public:
28         std::string Description;
29         std::string LastMessage;
30         int Count;
31         bool LastBlocked;
32         char LastLetter;
33
34         /** Create a new Snomask
35          */
36         Snomask() : Count(0), LastBlocked(false), LastLetter(0)
37         {
38         }
39
40         /** Sends a message to all opers with this snomask.
41          */
42         void SendMessage(const std::string &message, char letter);
43
44         /** Sends out the (last message repeated N times) message
45          */
46         void Flush();
47 };
48
49 /** Snomask manager handles routing of SNOMASK (usermode +s) messages to opers.
50  * Modules and the core can enable and disable snomask characters. If they do,
51  * then sending snomasks using these characters becomes possible.
52  */
53 class CoreExport SnomaskManager
54 {
55  public:
56         Snomask masks[26];
57
58         /** Create a new SnomaskManager
59          */
60         SnomaskManager();
61
62         /** Enable a snomask.
63          * @param letter The snomask letter to enable. Once enabled,
64          * server notices may be routed to users with this letter in
65          * their list, and users may add this letter to their list.
66          * @param description The descriptive text sent along with any
67          * server notices, at the start of the notice, e.g. "GLOBOPS".
68          */
69         void EnableSnomask(char letter, const std::string &description);
70
71         /** Write to all users with a given snomask (local server only)
72          * @param letter The snomask letter to write to
73          * @param text The text to send to the users
74          */
75         void WriteToSnoMask(char letter, const std::string &text);
76
77         /** Write to all users with a given snomask (local server only)
78          * @param letter The snomask letter to write to
79          * @param text A format string containing text to send
80          * @param ... Format arguments
81          */
82         void WriteToSnoMask(char letter, const char* text, ...) CUSTOM_PRINTF(3, 4);
83
84         /** Write to all users with a given snomask (sent globally)
85          * @param letter The snomask letter to write to
86          * @param text The text to send to the users
87          */
88         void WriteGlobalSno(char letter, const std::string &text);
89
90         /** Write to all users with a given snomask (sent globally)
91          * @param letter The snomask letter to write to
92          * @param text A format string containing text to send
93          * @param ... Format arguments
94          */
95         void WriteGlobalSno(char letter, const char* text, ...) CUSTOM_PRINTF(3, 4);
96
97
98         /** Called once per 5 seconds from the mainloop, this flushes any cached
99          * snotices. The way the caching works is as follows:
100          * Calls to WriteToSnoMask write to a cache, if the call is the same as it was
101          * for the previous call, then a count is incremented. If it is different,
102          * the previous message it just sent normally via NOTICE (with count if > 1)
103          * and the new message is cached. This acts as a sender in case the number of notices
104          * is not particularly significant, in order to keep notices going out.
105          */
106         void FlushSnotices();
107 };