summaryrefslogtreecommitdiff
path: root/src/snomasks.cpp
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-03-10 22:55:55 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-03-10 22:55:55 +0000
commit606aa8f09b64d9b779fe847f7f969b6c456f8343 (patch)
treef9313bbf3c8e639ef48b062fc7505391bba131dd /src/snomasks.cpp
parent255580c5f164b71a6186b42dd9f9650d0defc0a7 (diff)
Fix snomask stacking to only delay (last message repeated) part of the snomask
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11201 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/snomasks.cpp')
-rw-r--r--src/snomasks.cpp73
1 files changed, 40 insertions, 33 deletions
diff --git a/src/snomasks.cpp b/src/snomasks.cpp
index 13eb326bf..8415dad34 100644
--- a/src/snomasks.cpp
+++ b/src/snomasks.cpp
@@ -70,8 +70,6 @@ void SnomaskManager::WriteToSnoMask(char letter, const std::string &text)
if (n != SnoMasks.end())
{
n->second->SendMessage(text);
- // XXX: Always try flush here. This removes snomask stacking effectively, as it's too annoying in it's present form. This may be reworked for RC3, or delayed until post-release.
- n->second->Flush();
}
}
@@ -119,51 +117,60 @@ void Snomask::SendMessage(const std::string &message)
{
this->Flush();
LastMessage = message;
- }
- else
- {
- Count++;
- }
-}
-void Snomask::Flush()
-{
- if (this->LastMessage.empty())
- return;
+ 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());
- ServerInstance->Logs->Log("snomask", DEFAULT, "%s: %s", this->Description.c_str(), this->LastMessage.c_str());
- if (Count > 1)
- ServerInstance->Logs->Log("snomask", DEFAULT, "%s: (last message repeated %u times)", this->Description.c_str(), Count);
+ FOREACH_RESULT(I_OnSendSnotice, OnSendSnotice(mysnomask, desc, message));
+ LastBlocked = (MOD_RESULT == 1); // 1 blocks the message
- int MOD_RESULT = 0;
- char mysnomask = MySnomask;
- std::string desc = this->Description;
+ if (!LastBlocked)
+ {
+ /* Only opers can receive snotices, so we iterate the oper list */
+ std::list<User*>::iterator i = ServerInstance->Users->all_opers.begin();
- FOREACH_RESULT(I_OnSendSnotice, OnSendSnotice(mysnomask, desc, this->LastMessage));
+ 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());
+ }
- if (MOD_RESULT != 1) // 1 blocks the message
- {
- /* Only opers can receive snotices, so we iterate the oper list */
- std::list<User*>::iterator i = ServerInstance->Users->all_opers.begin();
+ i++;
+ }
+ }
+ }
+ Count++;
+}
- while (i != ServerInstance->Users->all_opers.end())
+void Snomask::Flush()
+{
+ if (Count > 1)
+ {
+ ServerInstance->Logs->Log("snomask", DEFAULT, "%s: (last message repeated %u times)", this->Description.c_str(), Count);
+ if (!LastBlocked)
{
- User* a = *i;
- if (IS_LOCAL(a) && a->IsModeSet('s') && a->IsNoticeMaskSet(mysnomask) && !a->quitting)
- {
+ /* Only opers can receive snotices, so we iterate the oper list */
+ std::list<User*>::iterator i = ServerInstance->Users->all_opers.begin();
- a->WriteServ("NOTICE %s :*** %s: %s", a->nick.c_str(), desc.c_str(), this->LastMessage.c_str());
- if (Count > 1)
+ 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: (last message repeated %u times)", a->nick.c_str(), this->Description.c_str(), Count);
}
- }
- i++;
+ i++;
+ }
}
- }
+ }
LastMessage = "";
- Count = 1;
+ LastBlocked = false;
+ Count = 0;
}