1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
20 #include "configreader.h"
27 SnomaskManager::SnomaskManager(InspIRCd* Instance) : ServerInstance(Instance)
32 SnomaskManager::~SnomaskManager()
36 bool SnomaskManager::EnableSnomask(char letter, const std::string &type)
38 if (SnoMasks.find(letter) == SnoMasks.end())
40 SnoMasks[letter] = type;
46 bool SnomaskManager::DisableSnomask(char letter)
48 SnoList::iterator n = SnoMasks.find(letter);
49 if (n != SnoMasks.end())
57 void SnomaskManager::WriteToSnoMask(char letter, const std::string &text)
59 /* Only send to snomask chars which are enabled */
60 SnoList::iterator n = SnoMasks.find(letter);
61 if (n != SnoMasks.end())
63 /* Only opers can receive snotices, so we iterate the oper list */
64 for (std::vector<userrec*>::iterator i = ServerInstance->all_opers.begin(); i != ServerInstance->all_opers.end(); i++)
67 if (IS_LOCAL(a) && a->modes[UM_SERVERNOTICE] && a->modes[UM_SNOMASK] && a->IsNoticeMaskSet(n->first))
69 /* send server notices to all with +ns */
70 a->WriteServ("NOTICE %s :*** %s: %s",a->nick, n->second.c_str(), text.c_str());
76 void SnomaskManager::WriteToSnoMask(char letter, const char* text, ...)
78 char textbuffer[MAXBUF];
81 va_start(argsPtr, text);
82 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
85 this->WriteToSnoMask(letter, std::string(textbuffer));
88 bool SnomaskManager::IsEnabled(char letter)
90 return (SnoMasks.find(letter) != SnoMasks.end());