cinchrb / cinch

The IRC Bot Building Framework
http://www.rubydoc.info/gems/cinch
MIT License
1k stars 180 forks source link

Possible bug in Cinch's hooks on random plugins #207

Closed woodruffw closed 8 years ago

woodruffw commented 9 years ago

Hi,

I'm using Cinch's hooks in yossarian-bot to drop messages from ignored users. The blacklisting code is as follows:

module Cinch
    module Plugin
        module ClassMethods
            def use_blacklist
                hook :pre, :for => [:match], :method => :not_blacklisted?
            end
        end

        def not_blacklisted?(m)
            !@bot.blacklist.include?(m.user.nick) && !@bot.blacklist.include?(m.user.host)
        end
    end
end

Every plugin calls use_blacklist after include Cinch::Plugin, but this seems to fail deterministically for a random group of plugins (meaning that the plugins that fail to hook stay the same between runs, but aren't related to each other in any way I can distinguish).

For example, the HAL plugin fails to hook the blacklist while the Magic8Ball plugin hooks it perfectly.

Could this be a bug in Cinch's hooking system? I'm having trouble finding a cause in my own code (use_blacklist gets invoked, execution passes cleanly through it for both working and non-working plugins).

I'm using Cinch 2.2.7 on Ruby 2.2.3 (MRI) for reference.

Best, William

dominikh commented 9 years ago

Is not_blacklisted? being called?

I cannot reproduce the issue. You would have to provide a minimal example, that is remove as much code as possible while still encountering the bug. Once the minimal example has been built, I can check if the error can be reproduced locally. yossarian-bot, as it is, is too large for me to test.

woodruffw commented 9 years ago

not_blacklisted? is not being called. I'll try to set up a minimal example later today.

woodruffw commented 8 years ago

Sorry for the late response. I've been testing a few minimal examples, and I haven't been able to reproduce the bug. I'll close this unless I can reproduce it in the future.

dominikh commented 8 years ago

@woodruffw c8ed88bec15f0afa09c8198dd5b9d560f2094137 should fix your issue.

woodruffw commented 8 years ago

Great, thank you so much!