You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 4, 2019. It is now read-only.
This new update should solve most underlying problem when extending slack-robot outside basic message handling, like events, custom response handler.
Here's the changes needed in core:
Expose RTM and Web API as public property (should be just minor property name changes)
This allow us to hook into custom events, while still providing easy request handling via robot.listen
constrobot=newSlackRobot(token);robot.rtm.on('message',message=>{if(message.subtype==='channel_join'){// new user joined channel}});
Expose DataStore API
Because we can access raw RTM events, we need to be able to get mapping between id and its object
const{ store }=robot;constchannel=store.getChannelById(channelId);
New stateless Response object creation. This will simplify many logic inside Response class
// we didn't store target id anymore, you have to explicitly provide in Text factoryrobot.listen('hello',(req,res)=>{consttext=Text('world',req.user.id);returnres.send(text);});
Remove robot.to?
Because we finally can create our own response object, maybe robot.to can be removed entirely
Remove res.async
This API is confusing and mostly useless because we can simply wrap async action using Promise ourselves. Given Promise is widely adopted, using res.async doesn't make sense anymore. Instead we use async/await
Creating reaction action forces us to store timestamp inside response instance. With new reaction factory, we can just pass the message we want to react.
// message object has ts (timestamp) propertyconstmessage={ts: '121341.12312'};constreaction=Reaction('+1',message);res.send(reaction);
Remove concurrency primitive
Using res.send allow us to remove awkward concurrency API. It's much more simple because we just use array and var args
This new update should solve most underlying problem when extending slack-robot outside basic message handling, like events, custom response handler.
Here's the changes needed in core:
This allow us to hook into custom events, while still providing easy request handling via
robot.listen
Because we can access raw RTM events, we need to be able to get mapping between id and its object
Response
object creation. This will simplify many logic inside Response classManually creating response object
Stateless response object
robot.to
?Because we finally can create our own response object, maybe
robot.to
can be removed entirelyres.async
This API is confusing and mostly useless because we can simply wrap async action using Promise ourselves. Given Promise is widely adopted, using
res.async
doesn't make sense anymore. Instead we useasync/await
Creating reaction action forces us to store timestamp inside response instance. With new reaction factory, we can just pass the message we want to react.
Using
res.send
allow us to remove awkward concurrency API. It's much more simple because we just use array and var argsThe text was updated successfully, but these errors were encountered: