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_wrapperintoclass bot_drupal_wrapperinbot_drupal_wrapper.class.incand several sub classes that extend it. - Makes changes to
bot_start.phpto use the class. - Cleans up some time durations, e.g.
5 * 60instead of300, 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.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | 918966-6.x-1.x.patch | 9.23 KB | Bevan |
| #4 | 918966-bot-6.x-1.1.patch | 8.6 KB | Bevan |
| bot-hook_irc_access.patch | 6.07 KB | Bevan | |
| bot_drupal_wrapper.class_.inc_.txt | 3.08 KB | Bevan |
Comments
Comment #1
Bevan commentedThis 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.Comment #2
morbus iffWhy'd you make each of the message types into a class?
Comment #3
Bevan commentedTo 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).
Comment #4
Bevan commentedThe attached patch is a backport for bot-6.x-1.1
Comment #5
mlncn commentedI 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.
Comment #6
Bevan commentedBenjamin; 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.
Comment #7
morbus iffThis has been committed to the drupal-7.x-dev branch. Thanks!
Comment #8
morbus iffComment #9
Bevan commentedCan we please add to 6.x too?
Comment #10
morbus iffI am no longer maintaining 6.x. Core has its own way of encouraging forward-movement, I have mine.
Comment #11
Bevan commentedOkay. Thank you for clarifying.
Comment #13
Bevan commentedI 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.