There is no way for bot-family modules to prevent other bot-family modules from sending a message to the channel. An access hook would allow features to be disabled when certain user(s) are present in a channel or when messages are sent by certain user(s).

The Bot Leash module would use this to — for example deny access to any feature when the message is from a user that is not in any of the bot's channels (by private chat).

The attached patch;

  • Refactors & simplifies class drupal_wrapper into class bot_drupal_wrapper in bot_drupal_wrapper.class.inc and several sub classes that extend it.
  • Makes changes to bot_start.php to use the class.
  • Cleans up some time durations, e.g. 5 * 60 instead of 300, for "5 minutes"
  • Adds support for hook_irc_access($hook, $data).

If any module returns FALSE for the access hook, then the $hook-hook is not invoked. Otherwise the $hook-hook is invoked as normal.

Comments

Bevan’s picture

This is related to #918996: Add hook_irc_bot_reply_action/message_alter() hook so that other modules can modify outgoing messages. which allows outgoing messages to be modified but does not stop incoming messages from being processed.

Bot Leash implements both of these hooks, but only this one (hook_irc_access()) allows it to achieve it's goal.

morbus iff’s picture

Why'd you make each of the message types into a class?

Bevan’s picture

To simplify the code, reduce the amount of duplicate code, reduce the number of times the list of IRC message types needs to be repeated (only twice now), make maintenance easier, and make it easier to add features at this early hook-invoking stage, such as the new access hook. From an OO point of view there is no more nor less purpose to the classes as the current/previous implementation (the class drupal_wrapper on it's own).

Bevan’s picture

StatusFileSize
new8.6 KB

The attached patch is a backport for bot-6.x-1.1

mlncn’s picture

I think there is a related bug, the zombie bot issue, that could maybe be cleaned up here also. The bot stays in the channel when all bot modules are disabled, which i expected. However, the bot also continues to function – to respond, do project URL lookups – when all modules are disabled, which was quite unexpected, and indicates no checking at all to see if maybe it shouldn't be talking.

Bevan’s picture

Benjamin; If I am not mistaken, I think that the admin/maintainer of the bot is expected to know that the bot will only respond to configuration changes when starts. Thus it won't respond to disabled modules until the php thread executing start_up.php is halted, and started it again. Only then can it "uninclude" the respective *.module files.

morbus iff’s picture

Status: Needs review » Fixed

This has been committed to the drupal-7.x-dev branch. Thanks!

morbus iff’s picture

Status: Fixed » Closed (fixed)
Bevan’s picture

Title: Add hook_irc_access() so that other modules can make the bot shut up » Drupal 6; Add hook_irc_access() so that other modules can make the bot shut up
Status: Closed (fixed) » Reviewed & tested by the community

Can we please add to 6.x too?

morbus iff’s picture

Status: Reviewed & tested by the community » Fixed

I am no longer maintaining 6.x. Core has its own way of encouraging forward-movement, I have mine.

Bevan’s picture

Okay. Thank you for clarifying.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Bevan’s picture

Title: Drupal 6; Add hook_irc_access() so that other modules can make the bot shut up » Drupal 6 backport of bot.smartirc.inc & hook_irc_access()
Status: Closed (fixed) » Closed (won't fix)
StatusFileSize
new9.23 KB

I re-rolled the patch to be based off of commit b683e46 ("SmartIRC class moved around, forcing all messages to be UTF-8.") and work with the latest 6.x-1.x (currently 6.x-1.2). It is also a git patch, created using a git clone of the bot project, so it applies cleanly.

If anyone continues to maintain this patch, this issue queue is the best place for it.