#include "inspircd.h"
+#include "modules/cap.h"
+#include "modules/whois.h"
+
+enum
+{
+ // From UnrealIRCd.
+ RPL_WHOISBOT = 335
+};
+
+class BotTag : public ClientProtocol::MessageTagProvider
+{
+ private:
+ SimpleUserModeHandler& botmode;
+ Cap::Reference ctctagcap;
+
+ public:
+ BotTag(Module* mod, SimpleUserModeHandler& bm)
+ : ClientProtocol::MessageTagProvider(mod)
+ , botmode(bm)
+ , ctctagcap(mod, "message-tags")
+ {
+ }
+
+ void OnPopulateTags(ClientProtocol::Message& msg) CXX11_OVERRIDE
+ {
+ User* const user = msg.GetSourceUser();
+ if (user && user->IsModeSet(botmode))
+ msg.AddTag("inspircd.org/bot", this, "");
+ }
+
+ bool ShouldSendTag(LocalUser* user, const ClientProtocol::MessageTagData& tagdata) CXX11_OVERRIDE
+ {
+ return ctctagcap.get(user);
+ }
+};
class ModuleBotMode : public Module, public Whois::EventListener
{
+ private:
SimpleUserModeHandler bm;
+ BotTag tag;
+
public:
ModuleBotMode()
: Whois::EventListener(this)
, bm(this, "bot", 'B')
+ , tag(this, bm)
{
}
{
if (whois.GetTarget()->IsModeSet(bm))
{
- whois.SendLine(335, "is a bot on " + ServerInstance->Config->Network);
+ whois.SendLine(RPL_WHOISBOT, "is a bot on " + ServerInstance->Config->Network);
}
}
};