<commit_before>const telegraf = require('telegraf');
const fs = require('fs');
const cd = require('./cdHomeFunction.js');
const ls = require('./lsFunction.js');
const cdReturnBack = require('./cdReturnBack.js');
const cdRute = require('./cdRute.js');
const getFile = require('./getFile');
const situation = require('./situation.js');

const TOKEN = process.env.TOKEN;
const bot = new telegraf(TOKEN);

let situationsValue = ' ';
let aux = ' ';
let cd_aux;
let count;
let countGet;

bot.on('text', function (ctx) {
  const instruction = ctx.update.message.text;
  count = instruction.split('cd /');
  countGet = instruction.split('get ');

  if(count[0] === '') {
    cd_aux = count[1];
    console.log(cd_aux);
  }else if(countGet[0] === '') {
    cd_aux = 'get';
    console.log(cd_aux);
  }else {
    cd_aux = instruction;
  }
  console.log(ctx.update.message.text);
  console.log(cd_aux);

  if(countGet[0] === '') {
    situationsValue = situation(ctx.update.message.text, aux);
  }else {
    situationsValue = situation(cd_aux, aux);
  }
  aux = situationsValue;
  console.log(aux);

  switch(cd_aux) {
    case 'cd':
      ctx.reply(situationsValue);
      cd(function (error, data){
        if(error){
          console.error('error', error);
        }else {
          data.forEach(function (file){
            ctx.reply(file);
          });
        }
      });
    break;

    case 'cd ..':
      ctx.reply(situationsValue);
      cdReturnBack(situationsValue, function(error, data) {
        if(error) {
          console.error('error', error);
        }else {
          data.forEach(function (file) {
            ctx.reply(file);
          });
        }
      });
    break;

    case 'get':
      ctx.reply(situationsValue);
      bot.telegram.sendDocument('11150012', {
        source: fs.createReadStream(getFile(situationsValue))
      });

    break;

    case 'ls':
      ctx.reply(situationsValue);
      ls(situationsValue, function (error, data) {
        if(error){
          console.error('error', error);
          ctx.reply('Path:' + situationsValue + ' incorrecto, introduzca cd u otra ruta para seguir');
        }else {
          data.forEach(function (file) {
            ctx.reply(file);
          });
        }
      });
    break;

    default:
      ctx.reply(situationsValue);
      cdRute(situationsValue, function (error, data) {
        if(error){
          console.error('error', error);
          ctx.reply('Path:' + ctx.update.message.text + ' no existe');
        }else{
          data.forEach(function (file){<commit_msg>getFile ya devuelve fichero en su formato correcto sin .dat<commit_after>const telegraf = require('telegraf');
const fs = require('fs');
const cd = require('./cdHomeFunction.js');
const ls = require('./lsFunction.js');
const cdReturnBack = require('./cdReturnBack.js');
const cdRute = require('./cdRute.js');
const getFile = require('./getFile');
const situation = require('./situation.js');

const TOKEN = process.env.TOKEN;
const bot = new telegraf(TOKEN);

let situationsValue = ' ';
let aux = ' ';
let cd_aux;
let count;
let countGet;

bot.on('text', function (ctx) {
  const instruction = ctx.update.message.text;
  count = instruction.split('cd /');
  countGet = instruction.split('get ');

  if(count[0] === '') {
    cd_aux = count[1];
    console.log(cd_aux);
  }else if(countGet[0] === '') {
    cd_aux = 'get';
    console.log(cd_aux);
  }else {
    cd_aux = instruction;
  }
  console.log(ctx.update.message.text);
  console.log(cd_aux);

  if(countGet[0] === '') {
    situationsValue = situation(ctx.update.message.text, aux);
  }else {
    situationsValue = situation(cd_aux, aux);
  }
  aux = situationsValue;
  console.log(aux);

  switch(cd_aux) {
    case 'cd':
      ctx.reply(situationsValue);
      cd(function (error, data){
        if(error){
          console.error('error', error);
        }else {
          data.forEach(function (file){
            ctx.reply(file);
          });
        }
      });
    break;

    case 'cd ..':
      ctx.reply(situationsValue);
      cdReturnBack(situationsValue, function(error, data) {
        if(error) {
          console.error('error', error);
        }else {
          data.forEach(function (file) {
            ctx.reply(file);
          });
        }
      });
    break;

    case 'get':
      ctx.reply(situationsValue);
      bot.telegram.sendDocument('11150012', {
        source: getFile(situationsValue)
      });

    break;

    case 'ls':
      ctx.reply(situationsValue);
      ls(situationsValue, function (error, data) {
        if(error){
          console.error('error', error);
          ctx.reply('Path:' + situationsValue + ' incorrecto, introduzca cd u otra ruta para seguir');
        }else {
          data.forEach(function (file) {
            ctx.reply(file);
          });
        }
      });
    break;

    default:
      ctx.reply(situationsValue);
      cdRute(situationsValue, function (error, data) {
        if(error){
          console.error('error', error);
          ctx.reply('Path:' + ctx.update.message.text + ' no existe');
        }else{
          data.forEach(function (file){
{'fraction_non_alphanumeric': 0.1581503788614727, 'fraction_numerical': 0.004662910433262095, 'mean_word_length': 2.4783783783783786, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2506444', 'n_tokens_mistral': 1656, 'n_tokens_neox': 1611, 'n_words': 314}