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 * ---------------------------------------------------
18 #include "configreader.h"
22 SnomaskManager::SnomaskManager(InspIRCd* Instance) : ServerInstance(Instance)
25 this->SetupDefaults();
28 SnomaskManager::~SnomaskManager()
32 bool SnomaskManager::EnableSnomask(char letter, const std::string &type)
34 if (SnoMasks.find(letter) == SnoMasks.end())
36 SnoMasks[letter] = type;
42 bool SnomaskManager::DisableSnomask(char letter)
44 SnoList::iterator n = SnoMasks.find(letter);
45 if (n != SnoMasks.end())
53 void SnomaskManager::WriteToSnoMask(char letter, const std::string &text)
55 /* Only send to snomask chars which are enabled */
56 SnoList::iterator n = SnoMasks.find(letter);
57 if (n != SnoMasks.end())
59 /* Only opers can receive snotices, so we iterate the oper list */
60 for (std::vector<userrec*>::iterator i = ServerInstance->all_opers.begin(); i != ServerInstance->all_opers.end(); i++)
63 if (IS_LOCAL(a) && a->modes[UM_SERVERNOTICE] && a->modes[UM_SNOMASK] && a->IsNoticeMaskSet(n->first))
65 /* send server notices to all with +ns */
66 a->WriteServ("NOTICE %s :*** %s: %s",a->nick, n->second.c_str(), text.c_str());
72 void SnomaskManager::WriteToSnoMask(char letter, const char* text, ...)
74 char textbuffer[MAXBUF];
77 va_start(argsPtr, text);
78 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
81 this->WriteToSnoMask(letter, std::string(textbuffer));
84 bool SnomaskManager::IsEnabled(char letter)
86 return (SnoMasks.find(letter) != SnoMasks.end());
89 void SnomaskManager::SetupDefaults()
91 this->EnableSnomask('c',"CONNECT"); /* Local connect notices */
92 this->EnableSnomask('C',"REMOTECONNECT"); /* Remote connect notices */
93 this->EnableSnomask('q',"QUIT"); /* Local quit notices */
94 this->EnableSnomask('Q',"REMOTEQUIT"); /* Remote quit notices */
95 this->EnableSnomask('k',"KILL"); /* Kill notices */
96 this->EnableSnomask('l',"LINK"); /* Link notices */
97 this->EnableSnomask('o',"OPER"); /* Oper up/down notices */
98 this->EnableSnomask('d',"DEBUG"); /* Debug notices */
99 this->EnableSnomask('x',"XLINE"); /* Xline notice (g/z/q/k/e) */
100 this->EnableSnomask('t',"STATS"); /* Local or remote stats request */
101 this->EnableSnomask('f',"FLOOD"); /* Flooding notices */