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)
30 this->SetupDefaults();
33 SnomaskManager::~SnomaskManager()
37 bool SnomaskManager::EnableSnomask(char letter, const std::string &type)
39 if (SnoMasks.find(letter) == SnoMasks.end())
41 SnoMasks[letter] = type;
47 bool SnomaskManager::DisableSnomask(char letter)
49 SnoList::iterator n = SnoMasks.find(letter);
50 if (n != SnoMasks.end())
58 void SnomaskManager::WriteToSnoMask(char letter, const std::string &text)
60 /* Only send to snomask chars which are enabled */
61 SnoList::iterator n = SnoMasks.find(letter);
62 if (n != SnoMasks.end())
64 /* Only opers can receive snotices, so we iterate the oper list */
65 for (std::vector<userrec*>::iterator i = ServerInstance->all_opers.begin(); i != ServerInstance->all_opers.end(); i++)
68 if (IS_LOCAL(a) && a->modes[UM_SERVERNOTICE] && a->modes[UM_SNOMASK] && a->IsNoticeMaskSet(n->first))
70 /* send server notices to all with +ns */
71 a->WriteServ("NOTICE %s :*** %s: %s",a->nick, n->second.c_str(), text.c_str());
77 void SnomaskManager::WriteToSnoMask(char letter, const char* text, ...)
79 char textbuffer[MAXBUF];
82 va_start(argsPtr, text);
83 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
86 this->WriteToSnoMask(letter, std::string(textbuffer));
89 bool SnomaskManager::IsEnabled(char letter)
91 return (SnoMasks.find(letter) != SnoMasks.end());
94 void SnomaskManager::SetupDefaults()
96 this->EnableSnomask('c',"CONNECT"); /* Local connect notices */
97 this->EnableSnomask('C',"REMOTECONNECT"); /* Remote connect notices */
98 this->EnableSnomask('q',"QUIT"); /* Local quit notices */
99 this->EnableSnomask('Q',"REMOTEQUIT"); /* Remote quit notices */
100 this->EnableSnomask('k',"KILL"); /* Kill notices */
101 this->EnableSnomask('n',"NICK"); /* Nickchange notices */
102 this->EnableSnomask('l',"LINK"); /* Link notices */
103 this->EnableSnomask('o',"OPER"); /* Oper up/down notices */
104 this->EnableSnomask('d',"DEBUG"); /* Debug notices */
105 this->EnableSnomask('x',"XLINE"); /* Xline notice (g/z/q/k/e) */