<commit_before>var HTTPS = require('https');
var cool = require('cool-ascii-faces');
var unirest = require('unirest');
var request = require('request');
var ImageService = require('groupme').ImageService;
var http = require('http');
var fs = require('fs');

var botID = process.env.BOT_ID;
var mashapeKey = process.env.MASHAPE_KEY;


function cardSearch(searchText) {
  var apiUrl = 'https://omgvamp-hearthstone-v1.p.mashape.com/cards/search/' + searchText + '?collectible=1';
  unirest.get(apiUrl)
    .header("X-Mashape-Key", mashapeKey)
    .end(function (result) {
      console.log(result.status);
      console.log(result.body);
      console.log("test: " +result.body[0].img);
      apiImgUrl = result.body[0].img;
      console.log("apiImgUrl: ");
      console.log(apiImgUrl);
      
    });
    return apiImgUrl;
}

function respond() {
  var request = JSON.parse(this.req.chunks[0]),
      botRegex = /^\!card$/;
  var searchText;
  var command = request.text.split(' ')[0];
  if(request.text && botRegex.test(command)) {
    searchText = request.text.substr(request.text.indexOf(' ')+1);
    this.res.writeHead(200);
    postMessage(searchText);
    this.res.end();
  } else {
    console.log("don't care");
    this.res.writeHead(200);
    this.res.end();
  }
}

function postMessage(searchText) {
  var options, body, botReq;
  var apiImgUrl = '';
  var apiUrl = 'https://omgvamp-hearthstone-v1.p.mashape.com/cards/search/' + searchText + '?collectible=1';
  unirest.get(apiUrl)
    .header("X-Mashape-Key", mashapeKey)
    .end(function (result) {
      console.log(result.status);
      console.log(result.body);
      console.log("test: " +result.body[0].img);
      apiImgUrl = result.body[0].img;
      console.log("apiImgUrl: ");
      console.log(apiImgUrl);
    });

  options = {
    hostname: 'api.groupme.com',
    path: '/v3/bots/post',
    method: 'POST'
  };
  console.log("apiImgUrl");
  console.log(apiImgUrl);
  body = {<commit_msg>scope<commit_after>var HTTPS = require('https');
var cool = require('cool-ascii-faces');
var unirest = require('unirest');
var request = require('request');
var ImageService = require('groupme').ImageService;
var http = require('http');
var fs = require('fs');

var botID = process.env.BOT_ID;
var mashapeKey = process.env.MASHAPE_KEY;

var apiImgUrl = '';
function cardSearch(searchText) {
  var apiUrl = 'https://omgvamp-hearthstone-v1.p.mashape.com/cards/search/' + searchText + '?collectible=1';
  unirest.get(apiUrl)
    .header("X-Mashape-Key", mashapeKey)
    .end(function (result) {
      console.log(result.status);
      console.log(result.body);
      console.log("test: " +result.body[0].img);
      apiImgUrl = result.body[0].img;
      console.log("apiImgUrl: ");
      console.log(apiImgUrl);
      
    });
    return apiImgUrl;
}

function respond() {
  var request = JSON.parse(this.req.chunks[0]),
      botRegex = /^\!card$/;
  var searchText;
  var command = request.text.split(' ')[0];
  if(request.text && botRegex.test(command)) {
    searchText = request.text.substr(request.text.indexOf(' ')+1);
    this.res.writeHead(200);
    cardSearch(searchText);
    postMessage();
    this.res.end();
  } else {
    console.log("don't care");
    this.res.writeHead(200);
    this.res.end();
  }
}

function postMessage() {
  var options, body, botReq;

  options = {
    hostname: 'api.groupme.com',
    path: '/v3/bots/post',
    method: 'POST'
  };
  console.log("apiImgUrl");
  console.log(apiImgUrl);
  body = {
{'fraction_non_alphanumeric': 0.17729482413497283, 'fraction_numerical': 0.009150700600514728, 'mean_word_length': 3.5135483870967743, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 3, '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': '541122', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1239, 'n_words': 205}