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 * ---------------------------------------------------
14 /* $Core: libIRCDsnomasks */
20 SnomaskManager::SnomaskManager(InspIRCd* Instance) : ServerInstance(Instance)
23 this->SetupDefaults();
26 SnomaskManager::~SnomaskManager()
30 void SnomaskManager::FlushSnotices()
32 // stub.. not yet written XXX
35 bool SnomaskManager::EnableSnomask(char letter, const std::string &type)
37 if (SnoMasks.find(letter) == SnoMasks.end())
39 Snomask *s = new Snomask(ServerInstance, letter, type);
46 bool SnomaskManager::DisableSnomask(char letter)
48 SnoList::iterator n = SnoMasks.find(letter);
49 if (n != SnoMasks.end())
51 delete n->second; // destroy the snomask
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 n->second->SendMessage(text);
68 void SnomaskManager::WriteToSnoMask(char letter, const char* text, ...)
70 char textbuffer[MAXBUF];
73 va_start(argsPtr, text);
74 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
77 this->WriteToSnoMask(letter, std::string(textbuffer));
80 bool SnomaskManager::IsEnabled(char letter)
82 return (SnoMasks.find(letter) != SnoMasks.end());
85 void SnomaskManager::SetupDefaults()
87 this->EnableSnomask('c',"CONNECT"); /* Local connect notices */
88 this->EnableSnomask('C',"REMOTECONNECT"); /* Remote connect notices */
89 this->EnableSnomask('q',"QUIT"); /* Local quit notices */
90 this->EnableSnomask('Q',"REMOTEQUIT"); /* Remote quit notices */
91 this->EnableSnomask('k',"KILL"); /* Kill notices */
92 this->EnableSnomask('K',"REMOTEKILL"); /* Remote kill notices */
93 this->EnableSnomask('l',"LINK"); /* Link notices */
94 this->EnableSnomask('o',"OPER"); /* Oper up/down notices */
95 this->EnableSnomask('d',"DEBUG"); /* Debug notices */
96 this->EnableSnomask('x',"XLINE"); /* Xline notice (g/z/q/k/e) */
97 this->EnableSnomask('t',"STATS"); /* Local or remote stats request */
98 this->EnableSnomask('f',"FLOOD"); /* Flooding notices */
101 /*************************************************************************************/
103 void Snomask::SendMessage(const std::string &message)
105 if (message != LastMessage)
108 LastMessage = message;
117 void Snomask::Flush()
119 /* Only opers can receive snotices, so we iterate the oper list */
120 for (std::list<User*>::iterator i = ServerInstance->all_opers.begin(); i != ServerInstance->all_opers.end(); i++)
123 if (IS_LOCAL(a) && a->IsModeSet('s') && a->IsModeSet('n') && a->IsNoticeMaskSet(MySnomask))
125 a->WriteServ("NOTICE %s :*** %s: %s", a->nick, this->Description.c_str(), this->LastMessage.c_str());
128 a->WriteServ("NOTICE %s :*** %s: (last message repeated %u times)", a->nick, this->Description.c_str(), Count);