diff options
Diffstat (limited to 'src/process.cpp')
-rw-r--r-- | src/process.cpp | 54 |
1 files changed, 37 insertions, 17 deletions
diff --git a/src/process.cpp b/src/process.cpp index b095ab40b..356a3b695 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -1,12 +1,20 @@ -/* Main processing code for Services. +/* + * Anope IRC Services * - * (C) 2003-2016 Anope Team - * Contact us at team@anope.org + * Copyright (C) 2003-2016 Anope Team <team@anope.org> * - * Please read COPYING and README for further details. + * This file is part of Anope. Anope is free software; you can + * redistribute it and/or modify it under the terms of the GNU + * General Public License as published by the Free Software + * Foundation, version 2. * - * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see see <http://www.gnu.org/licenses/>. */ #include "services.h" @@ -14,7 +22,7 @@ #include "protocol.h" #include "servers.h" #include "users.h" -#include "regchannel.h" +#include "event.h" void Anope::Process(const Anope::string &buffer) { @@ -50,13 +58,10 @@ void Anope::Process(const Anope::string &buffer) static const Anope::string proto_name = ModuleManager::FindFirstOf(PROTOCOL) ? ModuleManager::FindFirstOf(PROTOCOL)->name : ""; MessageSource src(source); - - EventReturn MOD_RESULT; - FOREACH_RESULT(OnMessage, MOD_RESULT, (src, command, params)); - if (MOD_RESULT == EVENT_STOP) - return; - ServiceReference<IRCDMessage> m("IRCDMessage", proto_name + "/" + command.lower()); + EventReturn MOD_RESULT = EventManager::Get()->Dispatch(&Event::Message::OnMessage, src, command, params); + + ServiceReference<IRCDMessage> m(proto_name + "/" + command.lower()); if (!m) { Log(LOG_DEBUG) << "unknown message from server (" << buffer << ")"; @@ -100,11 +105,26 @@ void IRCDProto::Parse(const Anope::string &buffer, Anope::string &source, Anope: } } -Anope::string IRCDProto::Format(const Anope::string &source, const Anope::string &message) +Anope::string IRCDProto::Format(IRCMessage &message) { + std::stringstream buffer; + + const Anope::string &source = message.GetSource().GetUID(); if (!source.empty()) - return ":" + source + " " + message; - else - return message; + buffer << ":" << source << " "; + + buffer << message.GetCommand(); + + for (unsigned int i = 0; i < message.GetParameters().size(); ++i) + { + buffer << " "; + + if (i + 1 == message.GetParameters().size()) + buffer << ":"; + + buffer << message.GetParameters()[i]; + } + + return buffer.str(); } |