summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/modules.h4
-rw-r--r--include/users.h4
-rw-r--r--src/modules.cpp2
-rw-r--r--src/users.cpp26
4 files changed, 34 insertions, 2 deletions
diff --git a/include/modules.h b/include/modules.h
index af36b7023..693fd41fb 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -401,7 +401,7 @@ enum Implementation
I_OnRawSocketAccept, I_OnRawSocketClose, I_OnRawSocketWrite, I_OnRawSocketRead, I_OnChangeLocalUserGECOS, I_OnUserRegister,
I_OnChannelPreDelete, I_OnChannelDelete, I_OnPostOper, I_OnSyncOtherMetaData, I_OnSetAway, I_OnCancelAway, I_OnUserList,
I_OnPostCommand, I_OnPostJoin, I_OnWhoisLine, I_OnBuildExemptList, I_OnRawSocketConnect, I_OnGarbageCollect, I_OnBufferFlushed,
- I_OnText, I_OnReadConfig, I_OnDownloadFile, I_OnPassCompare, I_OnRunTestSuite, I_OnNamesListItem,
+ I_OnText, I_OnReadConfig, I_OnDownloadFile, I_OnPassCompare, I_OnRunTestSuite, I_OnNamesListItem, I_OnNumeric,
I_END
};
@@ -1363,6 +1363,8 @@ class CoreExport Module : public Extensible
* module, then this will cause the nickname not to be displayed at all.
*/
virtual void OnNamesListItem(User* issuer, User* user, Channel* channel, std::string &prefixes, std::string &nick);
+
+ virtual int OnNumeric(User* user, unsigned int numeric, const std::string &text);
};
diff --git a/include/users.h b/include/users.h
index a63dd7cc6..d1f61932e 100644
--- a/include/users.h
+++ b/include/users.h
@@ -923,6 +923,10 @@ class CoreExport User : public connection
*/
void WriteServ(const char* text, ...);
+ void WriteNumeric(unsigned int numeric, const char* text, ...);
+
+ void WriteNumeric(unsigned int numeric, const std::string &text);
+
/** Write text to this user, appending CR/LF and prepending :nick!user@host of the user provided in the first parameter.
* @param user The user to prepend the :nick!user@host of
* @param text A std::string to send to the user
diff --git a/src/modules.cpp b/src/modules.cpp
index 4bfa16eca..6a870361b 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -194,7 +194,7 @@ void Module::OnBufferFlushed(User*) { }
void Module::OnText(User*, void*, int, const std::string&, char, CUList&) { }
void Module::OnRunTestSuite() { }
void Module::OnNamesListItem(User*, User*, Channel*, std::string&, std::string&) { }
-
+int Module::OnNumeric(User*, unsigned int, const std::string&) { return 0; }
ModuleManager::ModuleManager(InspIRCd* Ins) : ModCount(0), Instance(Ins)
{
diff --git a/src/users.cpp b/src/users.cpp
index aeb985237..286f08fe6 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -1153,6 +1153,32 @@ void User::WriteServ(const char* text, ...)
}
+void User::WriteNumeric(unsigned int numeric, const char* text, ...)
+{
+ va_list argsPtr;
+ char textbuffer[MAXBUF];
+
+ va_start(argsPtr, text);
+ vsnprintf(textbuffer, MAXBUF, text, argsPtr);
+ va_end(argsPtr);
+
+ this->WriteNumeric(numeric, std::string(textbuffer));
+}
+
+void User::WriteNumeric(unsigned int numeric, const std::string &text)
+{
+ char textbuffer[MAXBUF];
+ int MOD_RESULT = 0;
+
+ FOREACH_RESULT(I_OnNumeric, OnNumeric(this, numeric, text));
+
+ if (MOD_RESULT)
+ return;
+
+ snprintf(textbuffer,MAXBUF,":%s %u %s %s",ServerInstance->Config->ServerName, numeric, this->nick, text.c_str());
+ this->Write(std::string(textbuffer));
+}
+
void User::WriteFrom(User *user, const std::string &text)
{
char tb[MAXBUF];