johnmaguire / Cardinal

A Python IRC bot, designed to make adding functionality quick and simple. (est. 2013)
MIT License
100 stars 38 forks source link

Ignore other bots (+B mode) #158

Open johnmaguire opened 4 years ago

johnmaguire commented 4 years ago

If +B is set on a user, Cardinal should ignore their messages

CloudyGuyThompson commented 3 years ago

Started looking at this one - Do you have an example of what Cardinal sees when the decoder is running in bot.py?

I'm assuming we'd need to store the name from the message line (assuming it's even held in there) and if the name includes +B then do not send the self.event_manager.fire("irc.raw", command, line) and instead break?

EDIT: I'd run it myself in debug to see what it does but I'm currently on an M1 mac with no Docker support!

johnmaguire commented 3 years ago

@GuyT-DevOps You can setup the cardinal.bot.irc logger to show raw messages from the server - change this line to include the "file" and or "console" handler (Docker logs use the console handler): https://github.com/JohnMaguire/Cardinal/blob/d3262193e2a50610144d55f78a43b2ef4e2d5c74/config/config.example.json#L75

Alternatively you can listen for irc.raw in a plug-in and log the values.

I'm not positive if the IRC spec includes anything about showing +B mode in the messages from the server.

It may be necessary to make a NAMES request, and maybe even WHO requests or similar to determine if bot modes are set.

johnmaguire commented 3 years ago

https://ircv3.net/specs/extensions/multi-prefix-3.1

There is this which will show all prefixes in NAMES. I'm not sure if this is only channel membership or includes user modes. Probably just channel membership.

It may be necessary to make a NAMES/WHO call for the current channel, followed by WHOIS for users, to determine who is a bot. It may be the case that this is too slow/spammy. I am also not sure that we currently have WHOIS support built in. If we were to build it, it should probably work very similarly to the WHO command.

johnmaguire commented 3 years ago

OK, did some more digging -

There's quite a few different ways servers support this mode. They are mostly summed up here: https://github.com/ircv3/ircv3-ideas/issues/43#issuecomment-640027381

It looks like Unreal is considering adding a message tag similar to InspIRCd.

I'm not sure there's really a good, full solution to this today, without a lot of code to support various daemons.

johnmaguire commented 3 years ago

I think this is blocked on coming up with some method for actually detecting bots.

vwbusguy commented 3 years ago

In the meantime, is there any present way to configure an ignore_users style list to prevent Cardinal (globally) from responding to known bots or integrations?