summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-25 10:30:54 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-25 10:30:54 +0000
commit9c213ae9c6f9f694f5f85f22b6af507ceba55acb (patch)
tree65954f64ca3bd86369201e2e9418dbdcc1bc8933
parent0d4c597e61c12ab72e5002555801aa3d23eb6677 (diff)
Allow PRIVMSG and NOTICE targets of $<servermask> to the module events (this wasnt trivial and is almost a damn feature)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4539 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/cmd_notice.cpp21
-rw-r--r--src/cmd_privmsg.cpp7
-rw-r--r--src/modules/m_spanningtree.cpp20
3 files changed, 39 insertions, 9 deletions
diff --git a/src/cmd_notice.cpp b/src/cmd_notice.cpp
index b9bd536d0..fbbeafec0 100644
--- a/src/cmd_notice.cpp
+++ b/src/cmd_notice.cpp
@@ -47,13 +47,20 @@ void cmd_notice::Handle (const char** parameters, int pcnt, userrec *user)
return;
if ((parameters[0][0] == '$') && ((*user->oper) || (is_uline(user->server))))
{
- // notice to server mask
- const char* servermask = parameters[0] + 1;
- if (match(Config->ServerName,servermask))
- {
- NoticeAll(user, true, "%s",parameters[1]);
- }
- return;
+ int MOD_RESULT = 0;
+ std::string temp = parameters[1];
+ FOREACH_RESULT(I_OnUserPreNotice,OnUserPreNotice(user,(void*)parameters[0],TYPE_SERVER,temp,0));
+ if (MOD_RESULT)
+ return;
+ parameters[1] = (char*)temp.c_str();
+ // notice to server mask
+ const char* servermask = parameters[0] + 1;
+ if (match(Config->ServerName,servermask))
+ {
+ NoticeAll(user, true, "%s",parameters[1]);
+ }
+ FOREACH_MOD(I_OnUserMessage,OnUserNotice(user,(void*)parameters[0],TYPE_SERVER,parameters[1],0));
+ return;
}
char status = 0;
if ((*parameters[0] == '@') || (*parameters[0] == '%') || (*parameters[0] == '+'))
diff --git a/src/cmd_privmsg.cpp b/src/cmd_privmsg.cpp
index 30d766e82..1218eca39 100644
--- a/src/cmd_privmsg.cpp
+++ b/src/cmd_privmsg.cpp
@@ -45,12 +45,19 @@ void cmd_privmsg::Handle (const char** parameters, int pcnt, userrec *user)
if ((parameters[0][0] == '$') && ((*user->oper) || (is_uline(user->server))))
{
+ int MOD_RESULT = 0;
+ std::string temp = parameters[1];
+ FOREACH_RESULT(I_OnUserPreMessage,OnUserPreMessage(user,(void*)parameters[0],TYPE_SERVER,temp,0));
+ if (MOD_RESULT)
+ return;
+ parameters[1] = (char*)temp.c_str();
// notice to server mask
const char* servermask = parameters[0] + 1;
if (match(Config->ServerName,servermask))
{
ServerPrivmsgAll("%s",parameters[1]);
}
+ FOREACH_MOD(I_OnUserMessage,OnUserMessage(user,(void*)parameters[0],TYPE_SERVER,parameters[1],0));
return;
}
char status = 0;
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp
index 14680efd6..8901c4353 100644
--- a/src/modules/m_spanningtree.cpp
+++ b/src/modules/m_spanningtree.cpp
@@ -3468,7 +3468,7 @@ class ModuleSpanningTree : public Module
DoOneToOne(user->nick,"NOTICE",params,d->server);
}
}
- else
+ else if (target_type == TYPE_CHANNEL)
{
if (user->fd > -1)
{
@@ -3487,6 +3487,14 @@ class ModuleSpanningTree : public Module
}
}
}
+ else if (target_type == TYPE_SERVER)
+ {
+ char* target = (char*)dest;
+ std::deque<std::string> par;
+ par.push_back(target);
+ par.push_back(":"+text);
+ DoOneToMany(user->nick,"NOTICE",par);
+ }
}
virtual void OnUserMessage(userrec* user, void* dest, int target_type, const std::string &text, char status)
@@ -3505,7 +3513,7 @@ class ModuleSpanningTree : public Module
DoOneToOne(user->nick,"PRIVMSG",params,d->server);
}
}
- else
+ else if (target_type == TYPE_CHANNEL)
{
if (user->fd > -1)
{
@@ -3524,6 +3532,14 @@ class ModuleSpanningTree : public Module
}
}
}
+ else if (target_type == TYPE_SERVER)
+ {
+ char* target = (char*)dest;
+ std::deque<std::string> par;
+ par.push_back(target);
+ par.push_back(":"+text);
+ DoOneToMany(user->nick,"PRIVMSG",par);
+ }
}
virtual void OnBackgroundTimer(time_t curtime)