-
-
Notifications
You must be signed in to change notification settings - Fork 405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide urllib.parse.ParseResult
to plugins with URL triggers
#2413
Comments
You can implement it as a property, still deferring the work until the handler code asks for it (and caching the result once the property is accessed once, if that seems useful enough) but without making it a method call from plugin authors' perspective.
Nothing is missing: Each URL is a separate trigger for Thing is, I don't know that the extra API complexity of this idea (introducing a new nullable property on Trigger, or adding a different optional third argument only for URL callables) is worth it, when it's very easy for plugin authors to just take the matched URL and |
Before, I don't really understand why would the trigger expose a From my perspective, it's up to the plugin author to take advantage of |
Note: we could, however, have a better tutorial explaining that and showing the way. |
Giving it some more thought in light of two dissents, it's not such a big deal for the end-user to import |
I'll keep this issue as an invitation to do better tutorials, so it's a positive outcome from my perspective. ❤️ |
Requested Feature
Sopel should take better advantage of
urllib.parse
when responding to URLs and passing them off to plugins for handling. See discussion in #2412.What I have in mind is something along the lines of the following, and hopefully this is in the direction that @Exirel and @dgw were thinking.
Suppose the
Trigger
provided to the handler had new behavior available if the handler call was caused by a URL,Trigger.parse_url() -> urllib.parse.ParseResult
. In this hypothetical, the code in thewikipedia
plugin that caused us all to start thinking about this might look something like:But this is something I put together in less than an hour and definitely needs the eyes of the experts on it. In particular, I'm not sure how I feel about the method call, and don't know what's missing from this interface for messages that might contain multiple URLs or other things I'm not accounting for. I opted for a method here because it defers the work until the user actually wants the parsed result, but it's entirely possible that this needs to be implemented in some other manner.
Problems Solved
https://xkcd.com/1313/
Alternatives
No response
Notes
No response
The text was updated successfully, but these errors were encountered: