python-matrix-bot-api icon indicating copy to clipboard operation
python-matrix-bot-api copied to clipboard

Accessing client object from callbacks

Open vranki opened this issue 6 years ago • 1 comments

Is there a way to access the bot.client variable from the callback functions somehow? If so, it would be useful to document it.

If not, it should be made possible. Perhaps add the bot or the client as callback parameter?

Client is required for example for file upload.

vranki avatar Jan 21 '19 15:01 vranki

As it stands, callbacks aren't passed the bot or client. I hadn't considered that it was necessary for something like file upload, but now that you mention it, the functionality should certainly be added.

My main concern is preserving API compatibility with existing callbacks. Introducing a client parameter would break compatibility, unless some cleverness was used. Perhaps attempting a 3 parameter callback with a try statement and on failure falling back to 2 parameters? I'll give it some thought and provide updates here.

shawnanastasio avatar Jan 22 '19 04:01 shawnanastasio