summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-03-22 11:45:57 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-03-22 11:45:57 +0000
commit9ee525bec55521e9d911df40c2d8ca8b0212ee22 (patch)
tree38aa3a31ea0fed7db88d920bd3ab5c55fb276f81 /src
parentbec3231f00ba89deeb2c6d05022ed3071843e915 (diff)
Add WriteNumeric() to User and OnNumeric module event. Note that modules do not change the numeric text on the fly, as this involves needless allocations for numerics that arent being changed, so instead they block the original numeric and send out their own when needed.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9174 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/modules.cpp2
-rw-r--r--src/users.cpp26
2 files changed, 27 insertions, 1 deletions
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];