Closed impredicative closed 5 years ago
You could possibly do irc.Handler('PRIVMSG')(self.privmsg_func)
inside your __init__
.
If I do that, will privmsg_func
then receive self
as its first argument whenever it's called for each PRIVMSG, or not?
It should (as long as you do it with self.function
instead of Class.function
).
Example: https://github.com/luk3yx/lurklite/blob/master/lurklite/core.py#L254
I used miniirc.Handler('PRIVMSG')(self.privmsg_func)
in my __init__
, and this works. It wouldn't hurt to have an example of this in the miniirc readme. Thanks.
@luk3yx Whenever possible, I encourage documenting the above line or pattern of code somewhere in the readme. It is not obvious and is expected to be generally useful.
I have added some documentation, if there's a problem with it please let me know.
I will come around to the other preexisting issue later, but for now I'm curious about registering a handler which is a method in a class, and not a standalone function.
For example, I can easily start a target method in a thread which automatically gets
self
as its first argument. In a similar manner, I'd like to be able to register a handler which automatically getsself
as its first argument (assuming I registered it for a method, not a function). Is this possible? This could significantly simplify some code for me. If this description of the issue is not clear, I can share sample code. Thanks.