]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree.cpp
Added support for NOTICE
[user/henk/code/inspircd.git] / src / modules / m_spanningtree.cpp
index 367e5290d2580d42e58a2005799b07f1b02463ce..cd35e824d882e20a3005d2a772e5874d2df2e5a9 100644 (file)
@@ -53,6 +53,7 @@ class TreeSocket;
 bool DoOneToOne(std::string prefix, std::string command, std::deque<std::string> params, std::string target);
 bool DoOneToAllButSender(std::string prefix, std::string command, std::deque<std::string> params, std::string omit);
 bool DoOneToMany(std::string prefix, std::string command, std::deque<std::string> params);
+bool DoOneToAllButSenderRaw(std::string data,std::string omit);
 
 class TreeServer
 {
@@ -624,6 +625,7 @@ class TreeSocket : public InspSocket
                }
                TreeServer* Node = new TreeServer(servername,description,ParentOfThis,NULL);
                ParentOfThis->AddChild(Node);
+               params[3] = ":" + params[3];
                DoOneToAllButSender(prefix,"SERVER",params,prefix);
                Srv->SendOpers("*** Server \002"+prefix+"\002 introduced server \002"+servername+"\002 ("+description+")");
                return true;
@@ -724,10 +726,6 @@ class TreeSocket : public InspSocket
                                }
                        }
                        item++;
-                       if ((strchr(param.c_str(),' ')) && (!stripcolon))
-                       {
-                               param = ":"+param;
-                       }
                        n.push_back(param);
                }
                return n;
@@ -736,8 +734,6 @@ class TreeSocket : public InspSocket
        bool ProcessLine(std::string line)
        {
                Srv->Log(DEBUG,"inbound-line: '"+line+"'");
-
-               std::deque<std::string> rawparams = this->Split(line,false);
                std::deque<std::string> params = this->Split(line,true);
                std::string command = "";
                std::string prefix = "";
@@ -880,7 +876,7 @@ class TreeSocket : public InspSocket
                                                        return true;
                                                }
                                        }
-                                       return DoOneToAllButSender(prefix,command,rawparams,sourceserv);
+                                       return DoOneToAllButSenderRaw(line,sourceserv);
 
                                }
                                return true;
@@ -926,6 +922,21 @@ class TreeSocket : public InspSocket
        }
 };
 
+bool DoOneToAllButSenderRaw(std::string data,std::string omit)
+{
+       for (unsigned int x = 0; x < TreeRoot->ChildCount(); x++)
+       {
+               TreeServer* Route = TreeRoot->GetChild(x);
+               if ((Route->GetSocket()) && (Route->GetName() != omit) && (BestRouteTo(omit) != Route))
+               {
+                       TreeSocket* Sock = Route->GetSocket();
+                       log(DEBUG,"Sending RAW to %s",Route->GetName().c_str());
+                       Sock->WriteLine(data);
+               }
+       }
+       return true;
+}
+
 bool DoOneToAllButSender(std::string prefix, std::string command, std::deque<std::string> params, std::string omit)
 {
        log(DEBUG,"ALLBUTONE: Comes from %s SHOULD NOT go back to %s",prefix.c_str(),omit.c_str());
@@ -1214,6 +1225,33 @@ class ModuleSpanningTree : public Module
                return 0;
        }
 
+       virtual void OnUserNotice(userrec* user, void* dest, int target_type, std::string text)
+       {
+               if (target_type == TYPE_USER)
+               {
+                       userrec* d = (userrec*)dest;
+                       if ((std::string(d->server) != Srv->GetServerName()) && (std::string(user->server) == Srv->GetServerName()))
+                       {
+                               std::deque<std::string> params;
+                               params.clear();
+                               params.push_back(d->nick);
+                               params.push_back(":"+text);
+                               DoOneToOne(user->nick,"NOTICE",params,d->server);
+                       }
+               }
+               else
+               {
+                       if (std::string(user->server) == Srv->GetServerName())
+                       {
+                               chanrec *c = (chanrec*)dest;
+                               std::deque<std::string> params;
+                               params.push_back(c->name);
+                               params.push_back(":"+text);
+                               DoOneToMany(user->nick,"NOTICE",params);
+                       }
+               }
+       }
+
        virtual void OnUserMessage(userrec* user, void* dest, int target_type, std::string text)
        {
                if (target_type == TYPE_USER)