GithubHelp home page GithubHelp logo

Legal way to get raw events about mmpy_bot HOT 6 CLOSED

zba avatar zba commented on August 30, 2024
Legal way to get raw events

from mmpy_bot.

Comments (6)

unode avatar unode commented on August 30, 2024 1

There may be a misunderstanding here. We aren't restricting anything in mmpy_bot.

The driver used by this project and linked above is the core that handles the requests. It supports having one event handler function. This role is taken by the event handler in mmpy_bot.

This handler is not accessible to plugins as this was not part of mmpy_bot's design. If you need access to it, you have two options:

  1. Modify mmpy_bot's event handler code to expose events.
  2. Use the driver directly, without mmpy_bot and build your own framework on top of it.

If you choose 1, you are welcome to open a pull request with your contributions. Maintainers will review and decide upon it.

from mmpy_bot.

unode avatar unode commented on August 30, 2024

Hi @zba,

For "raw" access you may want to look into python-mattermost-autodriver which is how mmpy_bot interacts with mattermost.
You can enable debug information as described in usage.

If you want to implement conversational behavior in mmpy_bot, see also #140.

from mmpy_bot.

zba avatar zba commented on August 30, 2024

The problem is how mmpy bot handles events, i access driver correct,. Please read example i provide. The problem, that autodriver init single time, it is not subscription by itself, so mmpy loose connection to driver if i init it in plugin, so i had to make this dirty trick to pass events back to mmpy. But if another plugin do same, 1st one will not receive events in my example. It could be easy fixed by making event proxy in eventhandler class,
May be i highlighted it not enough :) i need reactions events, so this is why i need, raw, i happy already to use message listeners and they work, while i not reinit event listener in my plugin, so i made ugly solution to pass this event back to mmpy bot :) ,

I not real pythonist, but you can use EventEmitter template (just found a lot libraries around so can't suggest any)
which provide basically template
in init
self.events = EventEmmitter()
in event receiver (_handle_event() in your function) :
self.websocket_events.emit(eventName, eventData)
in module main class init
self.websocket_events = self.event_handler.websocket_events
in MyPlugin in init
self.wesocket_events.on('reaction_add', callback)
(or for more security you can export on() and once() methods)
I not real pythonist (more js), so I not sure if it best solution or not :) but access to events any way could make me and anybody like me happy :)

from mmpy_bot.

unode avatar unode commented on August 30, 2024

mmpy_bot currently only listens to posted events.

See #445 for another request to add support for post_edited and a suggestion on how to achieve it.
See also #377 and #386 for other discussion about other kinds of events.

Reactions would need a new approach given @listen_to doesn't make sense for them.

The point of mmpy_bot is that you don't have to interact with events at low level.
If you need that functionality, this is currently not supported without modifying mmpy_bot's source.
We could add support for different kinds of event handlers if a proposal is made and implemented.

Contributions are welcome.

from mmpy_bot.

zba avatar zba commented on August 30, 2024

Yes, i like i haven't too, but why not allow me also raw access as i have access to driver too ? The whole point of this issue is ask to add ability to use functions of driver not implemented in decorators.

from mmpy_bot.

zba avatar zba commented on August 30, 2024

Ah I got, i not need mmpy bot, because all it does is decorators on posts events, and i can just go with event model without decorators, hm, ok. I chose 2

from mmpy_bot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.