Skip to content

Commit

Permalink
vCards is written to single file
Browse files Browse the repository at this point in the history
  • Loading branch information
tallnato committed Nov 2, 2015
1 parent d81aac4 commit f03e528
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ build/Release
# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules

*.vcf
28 changes: 16 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,30 @@ var fs = require('fs');
slack = new Slack(config.slackToken);
vCard = vCard();

var vFile = config.organization + '.vcf';


//Check if file already exists
if (fs.existsSync(vFile)){
fs.unlinkSync(vFile);
}

slack.api("users.list", function(err, response) {
response.members.forEach(function(user) {

//set properties
vCard.firstName = user.profile.first_name;
vCard.lastName = user.profile.last_name;
vCard.organization = config.organization;
vCard.photo.attachFromUrl(user.profile.image_72, 'JPEG');
//set properties
vCard.firstName = user.profile.first_name;
vCard.lastName = user.profile.last_name;
vCard.organization = config.organization;
vCard.photo.attachFromUrl(user.profile.image_72, 'JPEG');

vCard.cellPhone = user.profile.phone;
vCard.title = user.profile.title;
vCard.email = user.profile.email;
vCard.cellPhone = user.profile.phone;
vCard.title = user.profile.title;
vCard.email = user.profile.email;

vCard.socialUrls['skype'] = user.profile.skype;
vCard.socialUrls['skype'] = user.profile.skype;

//save to file
vCard.saveToFile('./contacts/'+user.name+'.vcf');
//save vCard
fs.appendFile(vFile, vCard.getFormattedString());
});
});

Expand Down

0 comments on commit f03e528

Please sign in to comment.