Skip to content
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

Construct a system for inter-bot-module dependencies #30

Open
cbgbt opened this issue Jul 4, 2014 · 3 comments
Open

Construct a system for inter-bot-module dependencies #30

cbgbt opened this issue Jul 4, 2014 · 3 comments

Comments

@cbgbt
Copy link
Collaborator

cbgbt commented Jul 4, 2014

It was discussed that it would be neat if a module could expose an API to other modules.

For instance, say one module exposes link shortening capabilities to IRC users. It would be cool if it could expose a shortenLink() function to other modules, so they they could make their own messages more succinct.

Of course the bot would have to make sure that dependencies get resolved, and that modules are loaded in such a way that dependencies are available to eachother when needed. This is hard because currently moduleMan doesn't actually know when modules have finished loading. In addition, Dependency circles should probably be noticed.

Discussion of design and implementation of such a system should occur here.

@euank
Copy link
Member

euank commented Jul 4, 2014

See issue #3 as well.

@cbgbt
Copy link
Collaborator Author

cbgbt commented Jul 4, 2014

Do you think we should share package.json with npm? Might be better than having to create two different package files.

@euank
Copy link
Member

euank commented Jul 4, 2014

We can and I'm not sure. I've thought about a little. I was actually thinking about just hooking require for the modules and injecting all other modules as potential require-able things.

https://github.com/felixge/node-sandboxed-module is a related module to this.

However good an idea that looks like, though, I don't think it's doable. "require" is synchronous and we need to be able to depend on modules across the network too which cannot be sync.

However, that's a tangent. We can, of course, drop dependencies in package.json.

My original intent, though, was for modules to export this stuff. The module might have "module.exports.dependencies = ['sirc-google']" or whatever and then the module simply won't be run if the dependency isn't loaded (and an error logged). Likewise, a "module.exports.predependency = ['sirc-database']" specifying module wouldn't be initted unless the database module was already initted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants