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