summaryrefslogtreecommitdiff
path: root/src/snomasks.cpp
diff options
context:
space:
mode:
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2008-01-05 15:54:37 +0000
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2008-01-05 15:54:37 +0000
commit1c774ea51f6799ca18a1028486f2812fe487ebdc (patch)
treec5711530e90e5f2bc8c9a4909c15b71524ffcbd3 /src/snomasks.cpp
parent13a4f598b7e4ad56b5dc654d8f4b50b8a9851673 (diff)
Snomask stacking: not yet working (crashes), and not quite finished
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8637 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/snomasks.cpp')
-rw-r--r--src/snomasks.cpp49
1 files changed, 37 insertions, 12 deletions
diff --git a/src/snomasks.cpp b/src/snomasks.cpp
index 88714cf2d..f922703f2 100644
--- a/src/snomasks.cpp
+++ b/src/snomasks.cpp
@@ -29,14 +29,15 @@ SnomaskManager::~SnomaskManager()
void SnomaskManager::FlushSnotices()
{
-
+ // stub.. not yet written XXX
}
bool SnomaskManager::EnableSnomask(char letter, const std::string &type)
{
if (SnoMasks.find(letter) == SnoMasks.end())
{
- SnoMasks[letter] = type;
+ Snomask *s = new Snomask(ServerInstance, letter, type);
+ SnoMasks[letter] = s;
return true;
}
return false;
@@ -47,6 +48,7 @@ bool SnomaskManager::DisableSnomask(char letter)
SnoList::iterator n = SnoMasks.find(letter);
if (n != SnoMasks.end())
{
+ delete n->second; // destroy the snomask
SnoMasks.erase(n);
return true;
}
@@ -59,16 +61,7 @@ void SnomaskManager::WriteToSnoMask(char letter, const std::string &text)
SnoList::iterator n = SnoMasks.find(letter);
if (n != SnoMasks.end())
{
- /* Only opers can receive snotices, so we iterate the oper list */
- for (std::list<User*>::iterator i = ServerInstance->all_opers.begin(); i != ServerInstance->all_opers.end(); i++)
- {
- User* a = *i;
- if (IS_LOCAL(a) && a->IsModeSet('s') && a->IsModeSet('n') && a->IsNoticeMaskSet(n->first))
- {
- /* send server notices to all with +ns */
- a->WriteServ("NOTICE %s :*** %s: %s",a->nick, n->second.c_str(), text.c_str());
- }
- }
+ n->second->SendMessage(text);
}
}
@@ -105,3 +98,35 @@ void SnomaskManager::SetupDefaults()
this->EnableSnomask('f',"FLOOD"); /* Flooding notices */
}
+/*************************************************************************************/
+
+void Snomask::SendMessage(const std::string &message)
+{
+ if (message != LastMessage)
+ {
+ this->Flush();
+ LastMessage = message;
+ Count = 1;
+ }
+ else
+ {
+ Count++;
+ }
+}
+
+void Snomask::Flush()
+{
+ /* Only opers can receive snotices, so we iterate the oper list */
+ for (std::list<User*>::iterator i = ServerInstance->all_opers.begin(); i != ServerInstance->all_opers.end(); i++)
+ {
+ User* a = *i;
+ if (IS_LOCAL(a) && a->IsModeSet('s') && a->IsModeSet('n') && a->IsNoticeMaskSet(MySnomask))
+ {
+ 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);
+ }
+ }
+ }
+}