1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
17 #include "m_spanningtree/treesocket.h"
18 #include "m_spanningtree/treeserver.h"
19 #include "m_spanningtree/utils.h"
21 /* $ModDep: m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */
25 /** remote MOTD. leet, huh? */
26 bool TreeSocket::ServerMessage(const std::string &messagetype, const std::string &prefix, std::deque<std::string> ¶ms, const std::string &sourceserv)
28 if (params.size() >= 2)
32 const char* target = params[0].c_str();
33 std::string text = params[1].c_str();
35 if (Instance->Modes->FindPrefix(*target))
41 Channel* channel = Instance->FindChan(target);
45 if (messagetype == "PRIVMSG")
47 FOREACH_MOD_I(Instance, I_OnUserMessage, OnUserMessage(NULL, channel, TYPE_CHANNEL, text, status, except_list));
51 FOREACH_MOD_I(Instance, I_OnUserNotice, OnUserNotice(NULL, channel, TYPE_CHANNEL, text, status, except_list));
53 TreeServer* s = Utils->FindServer(prefix);
56 FOREACH_MOD_I(Instance, I_OnText, OnText(NULL, channel, TYPE_CHANNEL, text, status, except_list));
57 channel->WriteChannelWithServ(s->GetName().c_str(), "%s %s :%s", messagetype.c_str(), channel->name, text.c_str());
62 User* user = Instance->FindNick(target);
66 if (messagetype == "PRIVMSG")
68 FOREACH_MOD_I(Instance, I_OnUserMessage, OnUserMessage(NULL, user, TYPE_USER, text, 0, except_list));
72 FOREACH_MOD_I(Instance, I_OnUserNotice, OnUserNotice(NULL, user, TYPE_USER, text, 0, except_list));
74 TreeServer* s = Utils->FindServer(prefix);
77 FOREACH_MOD_I(Instance, I_OnText, OnText(NULL, user, TYPE_USER, text, status, except_list));
78 user->Write(":%s %s %s :%s", s->GetName().c_str(), messagetype.c_str(), user->nick, text.c_str());
84 /* Propogate as channel privmsg */
85 return Utils->DoOneToAllButSenderRaw(":" + prefix + " " + messagetype + " " + target + " :" + text, sourceserv, prefix, assign(messagetype), params);