+/*************************************************************************************/
+
+void Snomask::SendMessage(const std::string &message)
+{
+ if (message != LastMessage)
+ {
+ this->Flush();
+ LastMessage = message;
+ }
+ else
+ {
+ Count++;
+ }
+}
+
+void Snomask::Flush()
+{
+ if (this->LastMessage.empty())
+ return;
+
+ /* Only opers can receive snotices, so we iterate the oper list */
+ for (std::list<User*>::iterator i = ServerInstance->Users->all_opers.begin(); i != ServerInstance->Users->all_opers.end(); i++)
+ {
+ User* a = *i;
+ if (IS_LOCAL(a) && a->IsModeSet('s') && a->IsModeSet('n') && a->IsNoticeMaskSet(MySnomask) && !a->quitting)
+ {
+
+ a->WriteServ("NOTICE %s :*** %s: %s", a->nick, this->Description.c_str(), this->LastMessage.c_str());
+ if (Count > 1)
+ {
+ a->WriteServ("NOTICE %s :*** %s: (last message repeated %u times)", a->nick, this->Description.c_str(), Count);
+ }
+ }
+ }
+
+ if (!LocalOnly)
+ {
+ // XXX this is a bit ugly.
+ std::string sno;
+ sno[0] = MySnomask;
+
+ ServerInstance->PI->SendSNONotice(sno, this->Description + ": " + this->LastMessage);
+ if (Count > 1)
+ ServerInstance->PI->SendSNONotice(sno, this->Description + ": (last message repeated " + ConvToStr(Count) + " times)");
+ }
+
+ LastMessage = "";
+ Count = 1;
+}