2012-04-19 20:58:29 +02:00
|
|
|
/*
|
|
|
|
* InspIRCd -- Internet Relay Chat Daemon
|
2007-07-16 17:30:04 +00:00
|
|
|
*
|
2012-04-19 20:58:29 +02:00
|
|
|
* Copyright (C) 2010 Daniel De Graaf <danieldg@inspircd.org>
|
|
|
|
* Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
|
|
|
|
* Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
|
|
|
|
* Copyright (C) 2006 Craig Edwards <craigedwards@brainbox.cc>
|
2007-07-16 17:30:04 +00:00
|
|
|
*
|
2012-04-19 20:58:29 +02:00
|
|
|
* This file is part of InspIRCd. InspIRCd is free software: you can
|
|
|
|
* redistribute it and/or modify it under the terms of the GNU General Public
|
|
|
|
* License as published by the Free Software Foundation, version 2.
|
2007-07-16 17:30:04 +00:00
|
|
|
*
|
2012-04-19 20:58:29 +02:00
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2007-07-16 17:30:04 +00:00
|
|
|
*/
|
|
|
|
|
2012-04-19 20:58:29 +02:00
|
|
|
|
2012-04-14 18:03:25 -07:00
|
|
|
#ifndef SNOMASKS_H
|
|
|
|
#define SNOMASKS_H
|
2007-07-16 17:30:04 +00:00
|
|
|
|
2009-10-18 16:18:44 +00:00
|
|
|
class Snomask
|
2008-01-04 14:49:40 +00:00
|
|
|
{
|
2008-01-04 20:34:25 +00:00
|
|
|
public:
|
|
|
|
std::string Description;
|
2008-01-05 15:54:37 +00:00
|
|
|
std::string LastMessage;
|
2010-02-25 19:42:08 +00:00
|
|
|
int Count;
|
2009-03-10 22:55:55 +00:00
|
|
|
bool LastBlocked;
|
2010-02-25 19:42:08 +00:00
|
|
|
char LastLetter;
|
2008-01-04 14:49:40 +00:00
|
|
|
|
|
|
|
/** Create a new Snomask
|
|
|
|
*/
|
2010-02-25 19:42:08 +00:00
|
|
|
Snomask() : Count(0), LastBlocked(false), LastLetter(0)
|
2008-01-04 14:49:40 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-01-05 15:54:37 +00:00
|
|
|
/** Sends a message to all opers with this snomask.
|
|
|
|
*/
|
2010-02-25 19:42:08 +00:00
|
|
|
void SendMessage(const std::string &message, char letter);
|
2008-01-05 16:57:42 +00:00
|
|
|
|
2009-03-10 22:55:55 +00:00
|
|
|
/** Sends out the (last message repeated N times) message
|
2008-01-05 16:57:42 +00:00
|
|
|
*/
|
|
|
|
void Flush();
|
2008-01-04 14:49:40 +00:00
|
|
|
};
|
|
|
|
|
2012-04-19 10:30:08 +02:00
|
|
|
/** Snomask manager handles routing of SNOMASK (usermode +s) messages to opers.
|
2007-07-16 17:30:04 +00:00
|
|
|
* Modules and the core can enable and disable snomask characters. If they do,
|
|
|
|
* then sending snomasks using these characters becomes possible.
|
|
|
|
*/
|
2009-09-02 00:46:11 +00:00
|
|
|
class CoreExport SnomaskManager
|
2007-07-16 17:30:04 +00:00
|
|
|
{
|
|
|
|
public:
|
2010-02-25 19:42:08 +00:00
|
|
|
Snomask masks[26];
|
|
|
|
|
2007-07-16 17:30:04 +00:00
|
|
|
/** Create a new SnomaskManager
|
|
|
|
*/
|
2009-09-26 14:13:13 +00:00
|
|
|
SnomaskManager();
|
2008-01-04 14:49:40 +00:00
|
|
|
|
2007-07-16 17:30:04 +00:00
|
|
|
/** Enable a snomask.
|
|
|
|
* @param letter The snomask letter to enable. Once enabled,
|
|
|
|
* server notices may be routed to users with this letter in
|
|
|
|
* their list, and users may add this letter to their list.
|
|
|
|
* @param description The descriptive text sent along with any
|
|
|
|
* server notices, at the start of the notice, e.g. "GLOBOPS".
|
|
|
|
*/
|
2010-02-25 19:42:08 +00:00
|
|
|
void EnableSnomask(char letter, const std::string &description);
|
2008-01-04 14:49:40 +00:00
|
|
|
|
2009-04-18 19:51:24 +00:00
|
|
|
/** Write to all users with a given snomask (local server only)
|
2007-07-16 17:30:04 +00:00
|
|
|
* @param letter The snomask letter to write to
|
|
|
|
* @param text The text to send to the users
|
|
|
|
*/
|
|
|
|
void WriteToSnoMask(char letter, const std::string &text);
|
2008-01-04 14:49:40 +00:00
|
|
|
|
2009-04-18 19:51:24 +00:00
|
|
|
/** Write to all users with a given snomask (local server only)
|
2007-07-16 17:30:04 +00:00
|
|
|
* @param letter The snomask letter to write to
|
|
|
|
* @param text A format string containing text to send
|
|
|
|
* @param ... Format arguments
|
|
|
|
*/
|
2008-03-30 02:48:54 +00:00
|
|
|
void WriteToSnoMask(char letter, const char* text, ...) CUSTOM_PRINTF(3, 4);
|
2008-01-04 14:49:40 +00:00
|
|
|
|
2009-04-18 19:51:24 +00:00
|
|
|
/** Write to all users with a given snomask (sent globally)
|
|
|
|
* @param letter The snomask letter to write to
|
|
|
|
* @param text The text to send to the users
|
|
|
|
*/
|
|
|
|
void WriteGlobalSno(char letter, const std::string &text);
|
|
|
|
|
|
|
|
/** Write to all users with a given snomask (sent globally)
|
|
|
|
* @param letter The snomask letter to write to
|
|
|
|
* @param text A format string containing text to send
|
|
|
|
* @param ... Format arguments
|
|
|
|
*/
|
|
|
|
void WriteGlobalSno(char letter, const char* text, ...) CUSTOM_PRINTF(3, 4);
|
|
|
|
|
|
|
|
|
2008-01-04 14:49:40 +00:00
|
|
|
/** Called once per 5 seconds from the mainloop, this flushes any cached
|
|
|
|
* snotices. The way the caching works is as follows:
|
|
|
|
* Calls to WriteToSnoMask write to a cache, if the call is the same as it was
|
|
|
|
* for the previous call, then a count is incremented. If it is different,
|
|
|
|
* the previous message it just sent normally via NOTICE (with count if > 1)
|
|
|
|
* and the new message is cached. This acts as a sender in case the number of notices
|
|
|
|
* is not particularly significant, in order to keep notices going out.
|
|
|
|
*/
|
|
|
|
void FlushSnotices();
|
2007-07-16 17:30:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|