+/*************************************************************************************/
+
+void Snomask::SendMessage(const std::string &message)
+{
+ if (message != LastMessage)
+ {
+ 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<User*>::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++;
+ }
+ }
+ }
+ Count++;
+}
+
+void Snomask::Flush()
+{
+ if (Count > 1)
+ {
+ 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<User*>::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(), mesg.c_str());
+ }
+
+ i++;
+ }
+ }
+
+ }
+ LastMessage = "";
+ LastBlocked = false;
+ Count = 0;
+}