2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
6 * This file is part of InspIRCd. InspIRCd is free software: you can
7 * redistribute it and/or modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation, version 2.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "treeserver.h"
27 CmdResult CommandAddLine::Handle(User* usr, Params& params)
29 XLineFactory* xlf = ServerInstance->XLines->GetFactory(params[0]);
30 const std::string& setter = usr->nick;
34 ServerInstance->SNO->WriteToSnoMask('x', "%s sent me an unknown ADDLINE type (%s).", setter.c_str(), params[0].c_str());
41 xl = xlf->Generate(ServerInstance->Time(), ConvToNum<unsigned long>(params[4]), params[2], params[5], params[1]);
43 catch (ModuleException &e)
45 ServerInstance->SNO->WriteToSnoMask('x', "Unable to ADDLINE type %s from %s: %s", params[0].c_str(), setter.c_str(), e.GetReason().c_str());
48 xl->SetCreateTime(ConvToNum<time_t>(params[3]));
49 if (ServerInstance->XLines->AddLine(xl, NULL))
53 ServerInstance->SNO->WriteToSnoMask('X', "%s added timed %s%s for %s, expires in %s (on %s): %s",
54 setter.c_str(), params[0].c_str(), params[0].length() == 1 ? "-line" : "",
55 params[1].c_str(), InspIRCd::DurationString(xl->duration).c_str(),
56 InspIRCd::TimeString(xl->expiry).c_str(), params[5].c_str());
60 ServerInstance->SNO->WriteToSnoMask('X', "%s added permanent %s%s on %s: %s",
61 setter.c_str(), params[0].c_str(), params[0].length() == 1 ? "-line" : "",
62 params[1].c_str(), params[5].c_str());
65 TreeServer* remoteserver = TreeServer::Get(usr);
67 if (!remoteserver->IsBursting())
69 ServerInstance->XLines->ApplyLines();
80 CommandAddLine::Builder::Builder(XLine* xline, User* user)
81 : CmdBuilder(user, "ADDLINE")
84 push(xline->Displayable());
86 push_int(xline->set_time);
87 push_int(xline->duration);
88 push_last(xline->reason);