<commit_before>//
// Summary: invites an external user to the active channel (as a single guest channel)
// Install:
//    $ sudo npm install wt -g
//    $ wt init <youremail>
//    $ wt create invite.js --name slack-invite \
//                        --secret SLACK_TOKEN=<get it from https://api.slack.com/web> \
//                        --secret SLACK_COMMAND_TOKEN=<create one at https://slack.com/services Slash Commands> \
//                        --secret SLACK_DOMAIN=yourdomain \
//                        --secret SLACK_ALLOWED_CHANNEL_PREFIX=ext
// Usage:
//    /invite-guest <EMAIL>
//
var request = require('request-promise');
var token;
var domain;

module.exports =
    function (context, cb) {
      if (!context.data.SLACK_TOKEN) 
        return cb(null, "For invites to work you need a slack Admin token (SLACK_TOKEN)");
      
      if (context.data.SLACK_COMMAND_TOKEN !== context.data.token) 
        return cb(null, "Tokens don't match, make sure to use the token provided in the Slash Command integration (SLACK_COMMAND_TOKEN)");
      
      if (!context.data.SLACK_DOMAIN)
        return cb(null, "Please provide your slack domain (SLACK_DOMAIN)");
      
      var prefix = context.data.SLACK_ALLOWED_CHANNEL_PREFIX || 'ext';
      if (context.data.channel_name.slice(0, prefix.length) !== prefix)
        return cb(null, "You can only invite guests to channels starting with `ext`")
      
      var token = context.data.SLACK_TOKEN;
      var mail = context.data.text;
      var domain = context.data.SLACK_DOMAIN;<commit_msg>credits<commit_after>//
// Summary: invites an external user to the active channel (as a single guest channel)
// Install:
//    $ sudo npm install wt -g
//    $ wt init <youremail>
//    $ wt create invite.js --name slack-invite \
//                        --secret SLACK_TOKEN=<get it from https://api.slack.com/web> \
//                        --secret SLACK_COMMAND_TOKEN=<create one at https://slack.com/services Slash Commands> \
//                        --secret SLACK_DOMAIN=yourdomain \
//                        --secret SLACK_ALLOWED_CHANNEL_PREFIX=ext
// Usage:
//    /invite-guest <EMAIL>
//
// Credits to https://github.com/n4ch03 for the initial code
//
var request = require('request-promise');
var token;
var domain;

module.exports =
    function (context, cb) {
      if (!context.data.SLACK_TOKEN) 
        return cb(null, "For invites to work you need a slack Admin token (SLACK_TOKEN)");
      
      if (context.data.SLACK_COMMAND_TOKEN !== context.data.token) 
        return cb(null, "Tokens don't match, make sure to use the token provided in the Slash Command integration (SLACK_COMMAND_TOKEN)");
      
      if (!context.data.SLACK_DOMAIN)
        return cb(null, "Please provide your slack domain (SLACK_DOMAIN)");
      
      var prefix = context.data.SLACK_ALLOWED_CHANNEL_PREFIX || 'ext';
      if (context.data.channel_name.slice(0, prefix.length) !== prefix)
        return cb(null, "You can only invite guests to channels starting with `ext`")
      
      var token = context.data.SLACK_TOKEN;
      var mail = context.data.text;
      var domain = context.data.SLACK_DOMAIN;
{'fraction_non_alphanumeric': 0.11514195583596215, 'fraction_numerical': 0.0015772870662460567, 'mean_word_length': 2.402360515021459, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 5, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4284711', 'n_tokens_mistral': 961, 'n_tokens_neox': 949, 'n_words': 274}