1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2018-2020 Sadie Powell <sadie@witchery.services>
5  *   Copyright (C) 2013 Attila Molnar <attilamolnar@hush.com>
6  *
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.
10  *
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
14  * details.
15  *
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/>.
18  */
19 
20 
21 #include "inspircd.h"
22 
23 #include "main.h"
24 #include "commands.h"
25 #include "treeserver.h"
26 
FireEvent(Server * target,const char * cmd,ClientProtocol::TagMap & taglist)27 void CmdBuilder::FireEvent(Server* target, const char* cmd, ClientProtocol::TagMap& taglist)
28 {
29 	if (!Utils->Creator || Utils->Creator->dying)
30 		return;
31 
32 	FOREACH_MOD_CUSTOM(Utils->Creator->GetMessageEventProvider(), ServerProtocol::MessageEventListener, OnBuildMessage, (target, cmd, taglist));
33 	UpdateTags();
34 }
35 
FireEvent(User * target,const char * cmd,ClientProtocol::TagMap & taglist)36 void CmdBuilder::FireEvent(User* target, const char* cmd, ClientProtocol::TagMap& taglist)
37 {
38 	if (!Utils->Creator || Utils->Creator->dying)
39 		return;
40 
41 	FOREACH_MOD_CUSTOM(Utils->Creator->GetMessageEventProvider(), ServerProtocol::MessageEventListener, OnBuildMessage, (target, cmd, taglist));
42 	UpdateTags();
43 }
44 
UpdateTags()45 void CmdBuilder::UpdateTags()
46 {
47 	std::string taglist;
48 	if (!tags.empty())
49 	{
50 		char separator = '@';
51 		for (ClientProtocol::TagMap::const_iterator iter = tags.begin(); iter != tags.end(); ++iter)
52 		{
53 			taglist.push_back(separator);
54 			separator = ';';
55 			taglist.append(iter->first);
56 			if (!iter->second.value.empty())
57 			{
58 				taglist.push_back('=');
59 				taglist.append(iter->second.value);
60 			}
61 		}
62 		taglist.push_back(' ');
63 	}
64 	content.replace(0, tagsize, taglist);
65 	tagsize = taglist.length();
66 }
67 
Handle(User * user,Params & params)68 CmdResult CommandSNONotice::Handle(User* user, Params& params)
69 {
70 	ServerInstance->SNO->WriteToSnoMask(params[0][0], "From " + user->nick + ": " + params[1]);
71 	return CMD_SUCCESS;
72 }
73 
HandleServer(TreeServer * server,Params & params)74 CmdResult CommandEndBurst::HandleServer(TreeServer* server, Params& params)
75 {
76 	server->FinishBurst();
77 	return CMD_SUCCESS;
78 }
79