2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2013, 2017-2019 Sadie Powell <sadie@witchery.services>
5 * Copyright (C) 2012, 2015 Attila Molnar <attilamolnar@hush.com>
6 * Copyright (C) 2012 Shawn Smith <ShawnSmith0828@gmail.com>
7 * Copyright (C) 2012 Robby <robby@chatbelgie.be>
8 * Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
9 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
10 * Copyright (C) 2004, 2010 Craig Edwards <brain@inspircd.org>
12 * This file is part of InspIRCd. InspIRCd is free software: you can
13 * redistribute it and/or modify it under the terms of the GNU General Public
14 * License as published by the Free Software Foundation, version 2.
16 * This program is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
27 #include "modules/ctctags.h"
28 #include "modules/whois.h"
36 class BotTag : public ClientProtocol::MessageTagProvider
39 SimpleUserModeHandler& botmode;
40 CTCTags::CapReference ctctagcap;
43 BotTag(Module* mod, SimpleUserModeHandler& bm)
44 : ClientProtocol::MessageTagProvider(mod)
50 void OnPopulateTags(ClientProtocol::Message& msg) CXX11_OVERRIDE
52 User* const user = msg.GetSourceUser();
53 if (user && user->IsModeSet(botmode))
54 msg.AddTag("inspircd.org/bot", this, "");
57 bool ShouldSendTag(LocalUser* user, const ClientProtocol::MessageTagData& tagdata) CXX11_OVERRIDE
59 return ctctagcap.get(user);
63 class ModuleBotMode : public Module, public Whois::EventListener
66 SimpleUserModeHandler bm;
71 : Whois::EventListener(this)
72 , bm(this, "bot", 'B')
77 Version GetVersion() CXX11_OVERRIDE
79 return Version("Provides user mode +B to mark the user as a bot",VF_VENDOR);
82 void OnWhois(Whois::Context& whois) CXX11_OVERRIDE
84 if (whois.GetTarget()->IsModeSet(bm))
86 whois.SendLine(RPL_WHOISBOT, "is a bot on " + ServerInstance->Config->Network);
91 MODULE_INIT(ModuleBotMode)