]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/snomasks.h
Remove InspIRCd* parameters and fields
[user/henk/code/inspircd.git] / include / snomasks.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 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 : public Extensible
18 {
19  public:
20         char MySnomask;
21         std::string Description;
22         std::string LastMessage;
23         bool LastBlocked;
24         unsigned int Count;
25
26         /** Create a new Snomask
27          */
28         Snomask(char snomask, const std::string &description) : MySnomask(snomask), Description(description), LastMessage(""), Count(0)
29         {
30         }
31
32         /** Sends a message to all opers with this snomask.
33          */
34         void SendMessage(const std::string &message);
35
36         /** Sends out the (last message repeated N times) message
37          */
38         void Flush();
39 };
40
41 /** A list of snomasks which are valid, and their descriptive texts
42  */
43 typedef std::map<char, Snomask *> SnoList;
44
45 /** Snomask manager handles routing of SNOMASK (usermode +n) messages to opers.
46  * Modules and the core can enable and disable snomask characters. If they do,
47  * then sending snomasks using these characters becomes possible.
48  */
49 class CoreExport SnomaskManager
50 {
51  private:
52         /** Currently active snomask list
53          */
54         SnoList SnoMasks;
55
56         /** Set up the default (core available) snomask chars
57          */
58         void SetupDefaults();
59  public:
60         /** Create a new SnomaskManager
61          */
62         SnomaskManager();
63
64         /** Delete SnomaskManager
65          */
66         ~SnomaskManager();
67
68         /** Enable a snomask.
69          * @param letter The snomask letter to enable. Once enabled,
70          * server notices may be routed to users with this letter in
71          * their list, and users may add this letter to their list.
72          * @param description The descriptive text sent along with any
73          * server notices, at the start of the notice, e.g. "GLOBOPS".
74          * @return True if the snomask was enabled, false if it already
75          * exists.
76          */
77         bool EnableSnomask(char letter, const std::string &description);
78
79         /** Disable a snomask.
80          * @param letter The snomask letter to disable.
81          * @return True if the snomask was disabled, false if it didn't
82          * exist.
83          */
84         bool DisableSnomask(char letter);
85
86         /** Write to all users with a given snomask (local server only)
87          * @param letter The snomask letter to write to
88          * @param text The text to send to the users
89          */
90         void WriteToSnoMask(char letter, const std::string &text);
91
92         /** Write to all users with a given snomask (local server only)
93          * @param letter The snomask letter to write to
94          * @param text A format string containing text to send
95          * @param ... Format arguments
96          */
97         void WriteToSnoMask(char letter, const char* text, ...) CUSTOM_PRINTF(3, 4);
98
99         /** Write to all users with a given snomask (sent globally)
100          * @param letter The snomask letter to write to
101          * @param text The text to send to the users
102          */
103         void WriteGlobalSno(char letter, const std::string &text);
104
105         /** Write to all users with a given snomask (sent globally)
106          * @param letter The snomask letter to write to
107          * @param text A format string containing text to send
108          * @param ... Format arguments
109          */
110         void WriteGlobalSno(char letter, const char* text, ...) CUSTOM_PRINTF(3, 4);
111
112
113         /** Called once per 5 seconds from the mainloop, this flushes any cached
114          * snotices. The way the caching works is as follows:
115          * Calls to WriteToSnoMask write to a cache, if the call is the same as it was
116          * for the previous call, then a count is incremented. If it is different,
117          * the previous message it just sent normally via NOTICE (with count if > 1)
118          * and the new message is cached. This acts as a sender in case the number of notices
119          * is not particularly significant, in order to keep notices going out.
120          */
121         void FlushSnotices();
122
123         /** Check if a snomask is enabled.
124          * @param letter The snomask letter to check.
125          * @return True if the snomask has been enabled.
126          */
127         bool IsEnabled(char letter);
128 };
129
130 #endif