1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
14 #ifndef __SNOMASKS_H__
15 #define __SNOMASKS_H__
20 #include "configreader.h"
26 InspIRCd *ServerInstance;
28 /** Sends out a pending message
33 std::string Description;
34 std::string LastMessage;
37 /** Create a new Snomask
39 Snomask(InspIRCd* Instance, char snomask, const std::string &description)
41 ServerInstance = Instance;
43 Description = description;
46 /** Sends a message to all opers with this snomask.
48 void SendMessage(const std::string &message);
51 /** A list of snomasks which are valid, and their descriptive texts
53 typedef std::map<char, Snomask *> SnoList;
55 /** Snomask manager handles routing of SNOMASK (usermode +n) messages to opers.
56 * Modules and the core can enable and disable snomask characters. If they do,
57 * then sending snomasks using these characters becomes possible.
59 class CoreExport SnomaskManager : public Extensible
64 InspIRCd* ServerInstance;
66 /** Currently active snomask list
70 /** Set up the default (core available) snomask chars
74 /** Create a new SnomaskManager
76 SnomaskManager(InspIRCd* Instance);
78 /** Delete SnomaskManager
83 * @param letter The snomask letter to enable. Once enabled,
84 * server notices may be routed to users with this letter in
85 * their list, and users may add this letter to their list.
86 * @param description The descriptive text sent along with any
87 * server notices, at the start of the notice, e.g. "GLOBOPS".
88 * @return True if the snomask was enabled, false if it already
91 bool EnableSnomask(char letter, const std::string &description);
93 /** Disable a snomask.
94 * @param letter The snomask letter to disable.
95 * @return True if the snomask was disabled, false if it didn't
98 bool DisableSnomask(char letter);
100 /** Write to all users with a given snomask.
101 * @param letter The snomask letter to write to
102 * @param text The text to send to the users
104 void WriteToSnoMask(char letter, const std::string &text);
106 /** Write to all users with a given snomask.
107 * @param letter The snomask letter to write to
108 * @param text A format string containing text to send
109 * @param ... Format arguments
111 void WriteToSnoMask(char letter, const char* text, ...);
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.
121 void FlushSnotices();
123 /** Check if a snomask is enabled.
124 * @param letter The snomask letter to check.
125 * @return True if the snomask has been enabled.
127 bool IsEnabled(char letter);