X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fsnomasks.cpp;h=6c3824ae74e31f17ba86dc676607aa3902c9af56;hb=a36020d088d020b6e5941d205e555f982134fa41;hp=2309b9ac06cd840bc4adacc2f3b4ef7721c61669;hpb=2ebf1f0055bf5c4c74dae2a0b5dee6d9ad3cfeb0;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/snomasks.cpp b/src/snomasks.cpp index 2309b9ac0..6c3824ae7 100644 --- a/src/snomasks.cpp +++ b/src/snomasks.cpp @@ -2,8 +2,8 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd: (C) 2002-2008 InspIRCd Development Team - * See: http://www.inspircd.org/wiki/index.php/Credits + * InspIRCd: (C) 2002-2009 InspIRCd Development Team + * See: http://wiki.inspircd.org/Credits * * This program is free but copyrighted software; see * the file COPYING for details. @@ -11,7 +11,7 @@ * --------------------------------------------------- */ -/* $Core: libIRCDsnomasks */ +/* $Core */ #include "inspircd.h" #include @@ -24,7 +24,7 @@ SnomaskManager::SnomaskManager(InspIRCd* Instance) : ServerInstance(Instance) } SnomaskManager::~SnomaskManager() -{ +{ for (std::map::iterator i = SnoMasks.begin(); i != SnoMasks.end(); i++) { delete i->second; @@ -98,8 +98,10 @@ void SnomaskManager::SetupDefaults() this->EnableSnomask('Q',"REMOTEQUIT"); /* Remote quit notices */ this->EnableSnomask('k',"KILL"); /* Kill notices */ this->EnableSnomask('K',"REMOTEKILL"); /* Remote kill notices */ - this->EnableSnomask('l',"LINK"); /* Link notices */ + this->EnableSnomask('l',"LINK"); /* Linking notices */ + this->EnableSnomask('L',"REMOTELINK"); /* Remote linking notices */ this->EnableSnomask('o',"OPER"); /* Oper up/down notices */ + this->EnableSnomask('O',"REMOTEOPER"); /* Remote oper up/down notices */ this->EnableSnomask('A',"ANNOUNCEMENT"); /* formerly WriteOpers() - generic notices to all opers */ this->EnableSnomask('d',"DEBUG"); /* Debug notices */ this->EnableSnomask('x',"XLINE"); /* Xline notice (g/z/q/k/e) */ @@ -115,33 +117,67 @@ void Snomask::SendMessage(const std::string &message) { this->Flush(); LastMessage = message; + + std::string desc = this->Description; + int MOD_RESULT = 0; + char mysnomask = MySnomask; + ServerInstance->Logs->Log("snomask", DEFAULT, "%s: %s", desc.c_str(), message.c_str()); + + FOREACH_RESULT(I_OnSendSnotice, OnSendSnotice(mysnomask, desc, message)); + + LastBlocked = (MOD_RESULT == 1); // 1 blocks the message + + if (!LastBlocked) + { + /* Only opers can receive snotices, so we iterate the oper list */ + std::list::iterator i = ServerInstance->Users->all_opers.begin(); + + while (i != ServerInstance->Users->all_opers.end()) + { + User* a = *i; + if (IS_LOCAL(a) && a->IsModeSet('s') && a->IsNoticeMaskSet(mysnomask) && !a->quitting) + { + a->WriteServ("NOTICE %s :*** %s: %s", a->nick.c_str(), desc.c_str(), message.c_str()); + } + + i++; + } + } } - else - { - Count++; - } + Count++; } void Snomask::Flush() { - if (this->LastMessage.empty()) - return; - - /* Only opers can receive snotices, so we iterate the oper list */ - for (std::list::iterator i = ServerInstance->Users->all_opers.begin(); i != ServerInstance->Users->all_opers.end(); i++) + if (Count > 1) { - User* a = *i; - if (IS_LOCAL(a) && a->IsModeSet('s') && a->IsModeSet('n') && a->IsNoticeMaskSet(MySnomask) && !a->quitting) + std::string desc = this->Description; + std::string mesg = "(last message repeated "+ConvToStr(Count)+" times)"; + char mysnomask = MySnomask; + + ServerInstance->Logs->Log("snomask", DEFAULT, "%s: %s", desc.c_str(), mesg.c_str()); + + FOREACH_MOD(I_OnSendSnotice, OnSendSnotice(mysnomask, desc, mesg)); + + if (!LastBlocked) { + /* Only opers can receive snotices, so we iterate the oper list */ + std::list::iterator i = ServerInstance->Users->all_opers.begin(); - a->WriteServ("NOTICE %s :*** %s: %s", a->nick, this->Description.c_str(), this->LastMessage.c_str()); - if (Count > 1) + while (i != ServerInstance->Users->all_opers.end()) { - a->WriteServ("NOTICE %s :*** %s: (last message repeated %u times)", a->nick, this->Description.c_str(), Count); + User* a = *i; + if (IS_LOCAL(a) && a->IsModeSet('s') && a->IsNoticeMaskSet(mysnomask) && !a->quitting) + { + a->WriteServ("NOTICE %s :*** %s: %s", a->nick.c_str(), desc.c_str(), mesg.c_str()); + } + + i++; } } - } + } LastMessage = ""; - Count = 1; + LastBlocked = false; + Count = 0; }