1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/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__
17 class Snomask : public Extensible
20 InspIRCd *ServerInstance;
24 std::string Description;
25 std::string LastMessage;
29 /** Create a new Snomask
31 Snomask(InspIRCd* Instance, char snomask, const std::string &description) : ServerInstance(Instance), MySnomask(snomask), Description(description), LastMessage(""), Count(0)
35 /** Sends a message to all opers with this snomask.
37 void SendMessage(const std::string &message);
39 /** Sends out the (last message repeated N times) message
44 /** A list of snomasks which are valid, and their descriptive texts
46 typedef std::map<char, Snomask *> SnoList;
48 /** Snomask manager handles routing of SNOMASK (usermode +n) messages to opers.
49 * Modules and the core can enable and disable snomask characters. If they do,
50 * then sending snomasks using these characters becomes possible.
52 class CoreExport SnomaskManager
57 InspIRCd* ServerInstance;
59 /** Currently active snomask list
63 /** Set up the default (core available) snomask chars
67 /** Create a new SnomaskManager
69 SnomaskManager(InspIRCd* Instance);
71 /** Delete SnomaskManager
76 * @param letter The snomask letter to enable. Once enabled,
77 * server notices may be routed to users with this letter in
78 * their list, and users may add this letter to their list.
79 * @param description The descriptive text sent along with any
80 * server notices, at the start of the notice, e.g. "GLOBOPS".
81 * @return True if the snomask was enabled, false if it already
84 bool EnableSnomask(char letter, const std::string &description);
86 /** Disable a snomask.
87 * @param letter The snomask letter to disable.
88 * @return True if the snomask was disabled, false if it didn't
91 bool DisableSnomask(char letter);
93 /** Write to all users with a given snomask (local server only)
94 * @param letter The snomask letter to write to
95 * @param text The text to send to the users
97 void WriteToSnoMask(char letter, const std::string &text);
99 /** Write to all users with a given snomask (local server only)
100 * @param letter The snomask letter to write to
101 * @param text A format string containing text to send
102 * @param ... Format arguments
104 void WriteToSnoMask(char letter, const char* text, ...) CUSTOM_PRINTF(3, 4);
106 /** Write to all users with a given snomask (sent globally)
107 * @param letter The snomask letter to write to
108 * @param text The text to send to the users
110 void WriteGlobalSno(char letter, const std::string &text);
112 /** Write to all users with a given snomask (sent globally)
113 * @param letter The snomask letter to write to
114 * @param text A format string containing text to send
115 * @param ... Format arguments
117 void WriteGlobalSno(char letter, const char* text, ...) CUSTOM_PRINTF(3, 4);
120 /** Called once per 5 seconds from the mainloop, this flushes any cached
121 * snotices. The way the caching works is as follows:
122 * Calls to WriteToSnoMask write to a cache, if the call is the same as it was
123 * for the previous call, then a count is incremented. If it is different,
124 * the previous message it just sent normally via NOTICE (with count if > 1)
125 * and the new message is cached. This acts as a sender in case the number of notices
126 * is not particularly significant, in order to keep notices going out.
128 void FlushSnotices();
130 /** Check if a snomask is enabled.
131 * @param letter The snomask letter to check.
132 * @return True if the snomask has been enabled.
134 bool IsEnabled(char letter);