2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2015 Attila Molnar <attilamolnar@hush.com>
5 * Copyright (C) 2013-2015 Peter Powell <petpow@saberuk.com>
7 * This file is part of InspIRCd. InspIRCd is free software: you can
8 * redistribute it and/or modify it under the terms of the GNU General Public
9 * License as published by the Free Software Foundation, version 2.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "modules/cap.h"
24 static const char* MessageTypeStringSp[] = { "PRIVMSG ", "NOTICE " };
26 class ModuleIRCv3EchoMessage : public Module
31 ModuleIRCv3EchoMessage()
32 : cap(this, "echo-message")
36 void OnUserMessage(User* user, void* dest, int target_type, const std::string& text, char status, const CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE
41 std::string msg = MessageTypeStringSp[msgtype];
42 if (target_type == TYPE_USER)
44 User* destuser = static_cast<User*>(dest);
45 msg.append(destuser->nick);
47 else if (target_type == TYPE_CHANNEL)
50 msg.push_back(status);
52 Channel* chan = static_cast<Channel*>(dest);
53 msg.append(chan->name);
57 const char* servername = static_cast<const char*>(dest);
58 msg.append(servername);
60 msg.append(" :").append(text);
61 user->WriteFrom(user, msg);
64 Version GetVersion() CXX11_OVERRIDE
66 return Version("Provides the echo-message IRCv3.2 extension", VF_VENDOR);
70 MODULE_INIT(ModuleIRCv3EchoMessage)