<commit_before>'use strict';

var http = require('http');
var querystring = require('querystring');
var slack = require('slack-notify')(process.env.SLACK_HOOK_URL);
var request = require('request');
var prependHttp = require('prepend-http');

var config =  {
  username: process.env.USERNAME || 'slackshot',
  emoji: process.env.EMOJI || ':round_pushpin:',
  token: process.env.SLACK_TOKEN || void 0
};

http.createServer(function (req, res) {
  var body = '';
  req.on('data', function(chunk) {
    body += chunk;
  });

  req.on('end', function() {
    res.writeHead(200, "OK", {'Content-Type': 'text/html'});
    res.end();

    body = querystring.parse(body);
    console.log(body);

    handlePayload(body);
  });
}).listen(process.env.PORT || 1337);

function handlePayload(body){
  if(config.token && config.token !== body.token){
    return console.error('Token `' + body.token + '` didn\'t match environment variable');
  }

  var text = body.text.split(' ');
  var url = prependHttp(text[0]);

  request.get('http://api.screenshotlayer.com/api/capture', {
    access_key: process.env.SCREENSHOTLAYER_TOKEN,
    url: url,
    viewport: "1440x900",
    width: 900
  }, function (error, response, body) {
    if (!error && response.statusCode == 200) {

        console.log(response);
        console.log(body);

        slack.send({
          username: config.username,
          icon_emoji: config.emoji,
          channel: body.channel_id,
          text: '<' + url + '>',
          unfurl_links: true,<commit_msg>access key not working<commit_after>'use strict';

var http = require('http');
var querystring = require('querystring');
var slack = require('slack-notify')(process.env.SLACK_HOOK_URL);
var request = require('request');
var prependHttp = require('prepend-http');

var config =  {
  username: process.env.USERNAME || 'slackshot',
  emoji: process.env.EMOJI || ':round_pushpin:',
  token: process.env.SLACK_TOKEN || void 0
};

http.createServer(function (req, res) {
  var body = '';
  req.on('data', function(chunk) {
    body += chunk;
  });

  req.on('end', function() {
    res.writeHead(200, "OK", {'Content-Type': 'text/html'});
    res.end();

    body = querystring.parse(body);
    console.log(body);

    handlePayload(body);
  });
}).listen(process.env.PORT || 1337);

function handlePayload(body){
  if(config.token && config.token !== body.token){
    return console.error('Token `' + body.token + '` didn\'t match environment variable');
  }

  var text = body.text.split(' ');
  var url = prependHttp(text[0]);

  request.get('http://api.screenshotlayer.com/api/capture', {
    access_key: process.env.SCREENSHOTLAYER_TOKEN,
    url: url,
    viewport: "1440x900",
    width: 900
  }, function (error, response, body) {
    if (!error && response.statusCode == 200) {

        console.log("access_key=" + process.env.SCREENSHOTLAYER_TOKEN);
        console.log(response);
        console.log(body);

        slack.send({
          username: config.username,
          icon_emoji: config.emoji,
          channel: body.channel_id,
          text: '<' + url + '>',
          unfurl_links: true,
{'fraction_non_alphanumeric': 0.17130073505912433, 'fraction_numerical': 0.014062000639181848, 'mean_word_length': 3.396067415730337, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '2901693', 'n_tokens_mistral': 1082, 'n_tokens_neox': 1037, 'n_words': 202}