<commit_before>var transmissionService = require('../../services/transmissionService');
var prettyMs = require('pretty-ms');
// Setup
transmissionService.setup();

module.exports = {
  'regex': new RegExp('^(?=([sS]how)|([lL]ist)( (me|my))?( currently)? download(ing|s)).*$'),
  'run': function(input, context, callback) {
    var self = this;
    return transmissionService.find({}, function(error, result) {
      if (error) {
        return callback(error, null);
      } else {
        // var message = JSON.stringify(result, undefined, 2);
        // console.log(result);
        var torrents = result.torrents;
        var message = torrents.length+' active Torrent(s):\n';
        // List the available Torrents
        var len = torrents.length;
        for (var i=0; i<len; i++)
        {
          var torrent = torrents[i];
          message += (i+1)+'. '+ torrent.name + ' (' + prettyMs(torrent.eta * 1000) + ' remaining) \n';
        }
        var response = {
          'response': {<commit_msg>See #3. Add download percentange to display when listing active torrents.<commit_after>var transmissionService = require('../../services/transmissionService');
var prettyMs = require('pretty-ms');
// Setup
transmissionService.setup();

module.exports = {
  'regex': new RegExp('^(?=([sS]how)|([lL]ist)( (me|my))?( currently)? download(ing|s)).*$'),
  'run': function(input, context, callback) {
    var self = this;
    return transmissionService.find({}, function(error, result) {
      if (error) {
        return callback(error, null);
      } else {
        // var message = JSON.stringify(result, undefined, 2);
        // console.log(result);
        var torrents = result.torrents;
        var message = torrents.length+' active Torrent(s):\n';
        // List the available Torrents
        var len = torrents.length;
        for (var i=0; i<len; i++)
        {
          var torrent = torrents[i];
          // console.log(torrent);
          var stats;
          if (torrent.eta != -1)
          {
            var eta = prettyMs(torrent.eta * 1000) + ' remaining';
            var perc = (Math.round( (torrent.percentDone * 100) * 10 ) / 10 ) + '% downloaded';
            stats = perc + ' with ' + eta;
          } else {
            var stats = 'Completed Downloading';
          }
          message += (i+1)+'. '+ torrent.name + ' (' +  stats + ') \n';
        }
        var response = {
          'response': {
{'fraction_non_alphanumeric': 0.16605014385532266, 'fraction_numerical': 0.009453349773941636, 'mean_word_length': 2.3296853625171, 'pattern_counts': {'":': 0, '<': 5, '<?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': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7642625', 'n_tokens_mistral': 756, 'n_tokens_neox': 720, 'n_words': 178}