Skip to content

Commit

Permalink
Add global-routing snomask functions
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11314 e03df62e-2008-0410-955e-edbf42e46eb7
  • Loading branch information
danieldg committed Apr 18, 2009
1 parent 00d3b70 commit 97c7c3f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
18 changes: 16 additions & 2 deletions include/snomasks.h
Expand Up @@ -90,19 +90,33 @@ class CoreExport SnomaskManager : public Extensible
*/
bool DisableSnomask(char letter);

/** Write to all users with a given snomask.
/** Write to all users with a given snomask (local server only)
* @param letter The snomask letter to write to
* @param text The text to send to the users
*/
void WriteToSnoMask(char letter, const std::string &text);

/** Write to all users with a given snomask.
/** Write to all users with a given snomask (local server only)
* @param letter The snomask letter to write to
* @param text A format string containing text to send
* @param ... Format arguments
*/
void WriteToSnoMask(char letter, const char* text, ...) CUSTOM_PRINTF(3, 4);

/** Write to all users with a given snomask (sent globally)
* @param letter The snomask letter to write to
* @param text The text to send to the users
*/
void WriteGlobalSno(char letter, const std::string &text);

/** Write to all users with a given snomask (sent globally)
* @param letter The snomask letter to write to
* @param text A format string containing text to send
* @param ... Format arguments
*/
void WriteGlobalSno(char letter, const char* text, ...) CUSTOM_PRINTF(3, 4);


/** Called once per 5 seconds from the mainloop, this flushes any cached
* snotices. The way the caching works is as follows:
* Calls to WriteToSnoMask write to a cache, if the call is the same as it was
Expand Down
19 changes: 19 additions & 0 deletions src/snomasks.cpp
Expand Up @@ -73,6 +73,13 @@ void SnomaskManager::WriteToSnoMask(char letter, const std::string &text)
}
}

void SnomaskManager::WriteGlobalSno(char letter, const std::string& text)
{
WriteToSnoMask(letter, text);
letter = toupper(letter);
ServerInstance->PI->SendSNONotice(std::string(1, letter), text);
}

void SnomaskManager::WriteToSnoMask(char letter, const char* text, ...)
{
char textbuffer[MAXBUF];
Expand All @@ -85,6 +92,18 @@ void SnomaskManager::WriteToSnoMask(char letter, const char* text, ...)
this->WriteToSnoMask(letter, std::string(textbuffer));
}

void SnomaskManager::WriteGlobalSno(char letter, const char* text, ...)
{
char textbuffer[MAXBUF];
va_list argsPtr;

va_start(argsPtr, text);
vsnprintf(textbuffer, MAXBUF, text, argsPtr);
va_end(argsPtr);

this->WriteGlobalSno(letter, std::string(textbuffer));
}

bool SnomaskManager::IsEnabled(char letter)
{
return (SnoMasks.find(letter) != SnoMasks.end());
Expand Down

0 comments on commit 97c7c3f

Please sign in to comment.