-
Notifications
You must be signed in to change notification settings - Fork 399
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
filter event by type and subtype #37
Comments
Could also use a separator that is less likely to exist in an type/subtype from slack, like slapp.event('message:channel_join', (msg) => {
//...
}) The more I think about it the more I like doing something like that over adding another optional param (since we also have the optional filter for |
I like the idea of a convenience form of the API to filter by subtype. However, most commonly I'd like to filter for events of type |
At this point in time, subtypes are a concept only used in events of type Knowing this, here's another possible solution. A new method that specifically handles events of type slapp.onMessage(subtype: string|undefined, listenerFn);
slapp.onMessage(listenerFn); What I like about this is that it still shortens the API call for existing usages quite a bit. It also seems fully backwards-compatible. // existing
slapp.event('message', listenerFn);
// proposed
slapp.onMessage(listenerFn); Very much open to other ideas. |
We added support for this in Bolt v1 by
As an example, to listen to a message with a app.event('message', subtype('channel_join'), ({ message }) => {
console.log(message);
// Your logic here
} |
Why this was added only for the message event, subtype? It would be great to sort all of the events through all of the params available. app.event('user_change', async ({ event, logger, client}) => {
if(event.user.profile.status_emoji || event.user.profile.status_text) {
try {
CountPlusPlus('user_change');
await client.chat.postMessage({
channel: a
text: b,
thread_ts: c
});
} catch (error) {
logger.error(error);
}
}
}); Is the approach correct? I'm interested only in status_text or status_emoji changes, but as I can guess, the Event API counts even if the status_text or status_emoji are undefined/not specified, so if I don't need it for extra params, wouldn't be great to sort just like subtype event for any other params? |
I think it would be convenient to be able to filter an event by
type
andsubtype
. This can be accomplished currently w/ custommatch()
or catch-allevent(type)
handlers, but having a way to match via theevent()
fn would keep things more terse.I can think of 2 ways to tackle this:
.
in the string - depends on Slack not adding any.
's to their event types/subtypesThe text was updated successfully, but these errors were encountered: