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