]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/privmsg.cpp
Whoops, wrong pointer. write out 500 lines 'i will check my code twice', brain.
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / privmsg.cpp
index 0aa175c7019b5edeef906f9b68f6d033e7f84839..4a266a465657e054ed2fcd4f2f57fa65c9c933a9 100644 (file)
@@ -40,26 +40,49 @@ bool TreeSocket::ServerMessage(const std::string &messagetype, const std::string
 
                Channel* channel = Instance->FindChan(target);
                
-               if (target)
+               if (channel)
                {
                        if (messagetype == "PRIVMSG")
                        {
-                               FOREACH_MOD_I(Instance, I_OnUserMessage, OnUserMessage(NULL, channel, TYPE_SERVER, text, status, except_list));
+                               FOREACH_MOD_I(Instance, I_OnUserMessage, OnUserMessage(NULL, channel, TYPE_CHANNEL, text, status, except_list));
                        }
                        else
                        {
-                               FOREACH_MOD_I(Instance, I_OnUserNotice, OnUserNotice(NULL, channel, TYPE_SERVER, text, status, except_list));
+                               FOREACH_MOD_I(Instance, I_OnUserNotice, OnUserNotice(NULL, channel, TYPE_CHANNEL, text, status, except_list));
                        }
                        TreeServer* s = Utils->FindServer(prefix);
                        if (s)
                        {
-                               FOREACH_MOD_I(Instance, I_OnText, OnText(NULL, channel, TYPE_SERVER, text, status, except_list));
+                               FOREACH_MOD_I(Instance, I_OnText, OnText(NULL, channel, TYPE_CHANNEL, text, status, except_list));
                                channel->WriteChannelWithServ(s->GetName().c_str(), "%s %s :%s", messagetype.c_str(), channel->name, text.c_str());
                        }
                }
+               else
+               {
+                       User* user = Instance->FindNick(target);
+                       
+                       if (user)
+                       {
+                               if (messagetype == "PRIVMSG")
+                               {
+                                       FOREACH_MOD_I(Instance, I_OnUserMessage, OnUserMessage(NULL, user, TYPE_USER, text, 0, except_list));
+                               }
+                               else
+                               {
+                                       FOREACH_MOD_I(Instance, I_OnUserNotice, OnUserNotice(NULL, user, TYPE_USER, text, 0, except_list));
+                               }
+                               TreeServer* s = Utils->FindServer(prefix);
+                               if (s)
+                               {
+                                       FOREACH_MOD_I(Instance, I_OnText, OnText(NULL, user, TYPE_USER, text, status, except_list));
+                                       user->Write(":%s %s %s :%s", s->GetName().c_str(), messagetype.c_str(), user->nick, text.c_str());
+                               }
+
+                       }
+               }
 
                /* Propogate as channel privmsg */
-               return Utils->DoOneToAllButSenderRaw(":" + prefix + " " + messagetype + " " + channel->name + " :" + text, sourceserv, prefix, assign(messagetype), params);
+               return Utils->DoOneToAllButSenderRaw(":" + prefix + " " + messagetype + " " + target + " :" + text, sourceserv, prefix, assign(messagetype), params);
        }
        return true;
 }