mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 02:59:01 -04:00
Mark messages with inspircd.org/bot if the user has +B set.
This commit is contained in:
parent
0b66cad1b0
commit
180b8b6ab1
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "inspircd.h"
|
#include "inspircd.h"
|
||||||
|
#include "modules/cap.h"
|
||||||
#include "modules/whois.h"
|
#include "modules/whois.h"
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@ -28,13 +29,44 @@ enum
|
|||||||
RPL_WHOISBOT = 335
|
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 OnClientProtocolPopulateTags(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
|
class ModuleBotMode : public Module, public Whois::EventListener
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
SimpleUserModeHandler bm;
|
SimpleUserModeHandler bm;
|
||||||
|
BotTag tag;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ModuleBotMode()
|
ModuleBotMode()
|
||||||
: Whois::EventListener(this)
|
: Whois::EventListener(this)
|
||||||
, bm(this, "bot", 'B')
|
, bm(this, "bot", 'B')
|
||||||
|
, tag(this, bm)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user