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

Commands "falling through" to other modules / multiple matches on command? #231

Closed
phillipadsmith opened this issue Dec 12, 2016 · 5 comments

Comments

@phillipadsmith
Copy link
Member

phillipadsmith commented Dec 12, 2016

I was troubleshooting an issue with the "logging module" approach that was discussed in issue #188 that appeared when I switched to 4.0.0-beta.1

The issue appears to be that commands now "fall through" to other modules, or -- put another way -- it's possible to have multiple matches on the same command.

This seems like a major departure from how things work before, which I believe was that once a command matched that no further processing by other modules would happen?

Forgot to add the question: Is this a feature, or a bug?

@drkno
Copy link
Member

drkno commented Dec 12, 2016

Feature, it has been there for a few of the alpha versions due to an earlier feature request.
Add return true; at the end of your run method or set event.shouldAbort = true; within your module.

Logging may now be easier using middleware FYI (it was one of the reasons I added it, cause I wanted a less hacky solution). There is the ability to hook into both before and after.

@phillipadsmith
Copy link
Member Author

Logging may now be easier using middleware FYI (it was one of the reasons I added it, cause I wanted a less hacky solution).

Is there documentation on middleware?

Feature, it has been there for a few of the alpha versions due to an earlier feature request.
Add return true; at the end of your run method or set event.shouldAbort = true; within your module.

Okay, I'll give that a try.

@drkno
Copy link
Member

drkno commented Dec 12, 2016

Is there documentation on middleware?

WIP, I would have more if I had more time, it follows a similar format to most other node applications though.

Rough example (may have to check the arguments passed to the callback func for exact details):

// subscribe
exports.platform.use('<hook>', callbackFunc);
// unsubscribe
exports.platform.unuse('<hook>', callbackFunc);

const callbackFunc = (next, args...) => {
    // do stuff, arguments automatically passed unmodified to next middleware
    next();
};

can modify arguments:

const callbackFunc = (next, arg1,arg2) => {
    arg1 = 'foo';
    const newArg = 'baz';
    next(arg1, arg2, baz);
};

@phillipadsmith
Copy link
Member Author

Rough example (may have to check the arguments passed to the callback func for exact details):

Helpful.

Is there any middleware that's been developed yet to use as a reference?

@drkno
Copy link
Member

drkno commented Dec 12, 2016

Considering that it has only just been made, no. This is related to #227. Disable and admin may be ported to it if time permits, and maybe a compatibility layer will be added for hubot middleware.

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

No branches or pull requests

2 participants