Closed franciskim closed 9 years ago
For now, I've done the following:
slack.on('team_join', function (data) {
slack = new slackAPI({
'token': "foobar",
'logging': true
});
setTimeout(function () {
slack.sendPM(data.user.name, ":beers: Welcome to DEVANZ @" + data.user.name + "! :sharkdance:");
}, 10000);
setTimeout(function () {
slack = null;
}, 105000);
The above hack/workaround has proven not to work. Any ideas on refreshing the channel/chat data when someone new joins?
@franciskim I have just been looking into the same type of thing, am about to fork this so I can mess around to find something that will work. I'll let you know what I find
I haven't tested this at all, so this could be utterly useless but @franciskim I think something like this should work
slack.on('team_join', function(data) {
// make a request to the users.list method and save it to slackData.users
slack.reqAPI('users.list', {}, function(data) {
// this is probably not accessing that datastore correctly
slackData.users = data.members;
});
});
hey @benhinchley - yeah I'd say that won't be in the right scope. For now, I have done it the manual way, I have my script running via PM2, and when someone joins I just process.exit();
XD
@franciskim I just tested something similar and it works, so might be worth a shot? but haha good hack :P
That's good to hear @benhinchley - do you think the new user details will still be available in the subsequent calls? I think it would just stay in the scope of slack.on('team_join', function(data) {
but I could be wrong.
addressed in https://github.com/xBytez/slackbotapi/pull/19
This could be considered a more general JavaScript question.
I've made a 'greeter' bot - when someone joins, it'll message them a series of things.
For me to do this, I've needed to re-instantiate the slackAPI when someone joins:
I believe this resulted in multiple slackAPI instances being instantiated, and due to the lack of my JavaScript knowledge I do not know a better way to handle this.
The below code needs to be triggered to refresh the user list, as trying to PM a new user that has joined will error:
Any help is appreciated!