1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 #include "configreader.h"
20 SnomaskManager::SnomaskManager(InspIRCd* Instance) : ServerInstance(Instance)
23 this->SetupDefaults();
26 SnomaskManager::~SnomaskManager()
30 bool SnomaskManager::EnableSnomask(char letter, const std::string &type)
32 if (SnoMasks.find(letter) == SnoMasks.end())
34 SnoMasks[letter] = type;
40 bool SnomaskManager::DisableSnomask(char letter)
42 SnoList::iterator n = SnoMasks.find(letter);
43 if (n != SnoMasks.end())
51 void SnomaskManager::WriteToSnoMask(char letter, const std::string &text)
53 /* Only send to snomask chars which are enabled */
54 SnoList::iterator n = SnoMasks.find(letter);
55 if (n != SnoMasks.end())
57 /* Only opers can receive snotices, so we iterate the oper list */
58 for (std::vector<userrec*>::iterator i = ServerInstance->all_opers.begin(); i != ServerInstance->all_opers.end(); i++)
61 if (IS_LOCAL(a) && a->IsModeSet('s') && a->IsModeSet('n') && a->IsNoticeMaskSet(n->first))
63 /* send server notices to all with +ns */
64 a->WriteServ("NOTICE %s :*** %s: %s",a->nick, n->second.c_str(), text.c_str());
70 void SnomaskManager::WriteToSnoMask(char letter, const char* text, ...)
72 char textbuffer[MAXBUF];
75 va_start(argsPtr, text);
76 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
79 this->WriteToSnoMask(letter, std::string(textbuffer));
82 bool SnomaskManager::IsEnabled(char letter)
84 return (SnoMasks.find(letter) != SnoMasks.end());
87 void SnomaskManager::SetupDefaults()
89 this->EnableSnomask('c',"CONNECT"); /* Local connect notices */
90 this->EnableSnomask('C',"REMOTECONNECT"); /* Remote connect notices */
91 this->EnableSnomask('q',"QUIT"); /* Local quit notices */
92 this->EnableSnomask('Q',"REMOTEQUIT"); /* Remote quit notices */
93 this->EnableSnomask('k',"KILL"); /* Kill notices */
94 this->EnableSnomask('K',"REMOTEKILL"); /* Remote kill notices */
95 this->EnableSnomask('l',"LINK"); /* Link notices */
96 this->EnableSnomask('o',"OPER"); /* Oper up/down notices */
97 this->EnableSnomask('d',"DEBUG"); /* Debug notices */
98 this->EnableSnomask('x',"XLINE"); /* Xline notice (g/z/q/k/e) */
99 this->EnableSnomask('t',"STATS"); /* Local or remote stats request */
100 this->EnableSnomask('f',"FLOOD"); /* Flooding notices */