Closed flotwig closed 7 years ago
The issue with that is it either creates a dependency between the core and the link_announcer plugin or it adds code to the core which is specific to a single plugin. Perhaps adding some more syntax to the regex hooks to add a priority system would be cleaner and more generic?
So something like:
@hook.regex(LINK_RE, priority=LOWEST, fallback=True)
def link_announce(...):
...
@hook.regex(YOUTUBE_RE, priority=NORMAL)
def youtube(...):
...
So link_announce
would only be called if no other regex hooks of a higher priority matched
That's actually a much better idea. Then we could have the default priority be NORMAL
and it wouldn't require code changes from the plugins, just the core and link_announcer.py
. I can't think of any unintended side effects this could have.
I can test it out and open a PR, should have something up by tomorrow
https://github.com/snoonetIRC/CloudBot/blob/721b2607fbb857c8324cc0720fda619ea34a70b3/plugins/link_announcer.py#L8
This line is getting pretty lengthy, it would be nice to see this refactored in some way.
My idea for this is that we could add some sort of hook which individual plugins could call to add their URLs to the blacklist.
So for example, in
spotify.py
, we could do something like this:@hook.url_blacklist("spotify.com")
And the same for each plugin which snarfs URLs.
That would move the hard-coded URLs out of the link announcer code and into the plugins which duplicate the snarfing functionality, which would be cleaner.