<commit_before>'use strict';
var amqp = require('amqplib/callback_api');
var fs = require('fs');
var path = require('path');

var rabbit_chat = {

  help: function () {
    var banner = fs.readFileSync(path.resolve(__dirname, '../banner.txt'));
    console.log(banner.toString());
    console.log("\n\
Usage: rabbit_chat -option [parameter] \n\n\
    options: \n\n\
        -h: Help menu \n\n\
        -v: Get rabbit_chat version \n\n\
        -a: Add a new channel \n\n\
        -g: Get existing channels \n\
            You have to set the user with --u option. \n\n\
        -l: Listen in a existing channel. \n\
            You have to set the user with --u option. \n\n\
        -w: Write a message in a channel.\n");
  },
  version: function() {
    fs.readFile(path.resolve(__dirname, '../package.json'), 'utf8', function(err, data) {
      if (err) throw err;
       console.log(JSON.parse(data).version);
    });
  },
  addChannel: function (user, ch_name) {
    fs.appendFile(path.resolve(__dirname, '..', 'data', 'users_channels', `${user}.txt`), ch_name + '\n', 'utf8', function (err) {
      if (err) throw err;
    });
  },
  getChannels: function (user) {
    fs.readFile(path.resolve(__dirname, '..', 'data', 'users_channels', `${user}.txt`), function (err, data) {
      if (err) throw err;
      var array = data.toString().split("\n");
      for (var i in array) {
        console.log(array[i]);
      }
    });
  },
  listenChannel: function(ch_name) {
    amqp.connect('amqp://localhost', function(err, connection) {
      connection.createChannel(function(err, channel) {
        var exchange = 'chat';

        channel.assertExchange(exchange, 'topic', {durable:false});

        channel.assertQueue('', {exclusive: true}, function(err, queue) {
          console.log("Waiting for messages in %s. To exit press CTRL+C", ch_name);
          ch_name.forEach(function(key) {
            channel.bindQueue(queue.queue, exchange, key);
          });
          channel.consume(queue.queue, function(msg) {
            console.log("%s", msg.content.toString());
          }, {noAck: true});
        });
      });
    });<commit_msg>Minor change<commit_after>'use strict';
var amqp = require('amqplib/callback_api');
var fs = require('fs');
var path = require('path');

var rabbit_chat = {

  help: function () {
    var banner = fs.readFileSync(path.resolve(__dirname, '../banner.txt'));
    console.log(banner.toString());
    console.log("\n\
Usage: rabbit_chat -option [parameter] \n\n\
    options: \n\n\
        -h: Help menu \n\n\
        -v: Get rabbit_chat version \n\n\
        -a: Add a new channel \n\n\
        -g: Get existing channels \n\
            You have to set the user with --u option. \n\n\
        -l: Listen in a existing channel. \n\
            You have to set the user with --u option. \n\n\
        -w: Write a message in a channel.\n");
  },
  version: function() {
    fs.readFile(path.resolve(__dirname, '../package.json'), 'utf8',
                function(err, data) {
                  if (err) throw err;
                  console.log(JSON.parse(data).version);
                });
  },
  addChannel: function (user, ch_name) {
    fs.appendFile(path.resolve(__dirname, '..', 'data', 'users_channels', `${user}.txt`),
                  ch_name + '\n', 'utf8', function (err) {
                    if (err) throw err;
                  });
  },
  getChannels: function (user) {
    fs.readFile(path.resolve(__dirname, '..', 'data', 'users_channels', `${user}.txt`),
                function (err, data) {
                  if (err) throw err;
                  var array = data.toString().split("\n");
                  for (var i in array) {
                    console.log(array[i]);
                  }
                });
  },
  listenChannel: function(ch_name) {
    amqp.connect('amqp://localhost', function(err, connection) {
      connection.createChannel(function(err, channel) {
        var exchange = 'chat';

        channel.assertExchange(exchange, 'topic', {durable:false});

        channel.assertQueue('', {exclusive: true}, function(err, queue) {
          console.log("Waiting for messages in %s. To exit press CTRL+C", ch_name);
          ch_name.forEach(function(key) {
            channel.bindQueue(queue.queue, exchange, key);
          });
          channel.consume(queue.queue, function(msg) {
            console.log("%s", msg.content.toString());
          }, {noAck: true});
        });
      });
    });
{'fraction_non_alphanumeric': 0.16651785714285713, 'fraction_numerical': 0.0008928571428571428, 'mean_word_length': 2.16678445229682, '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': '66993', 'n_tokens_mistral': 1405, 'n_tokens_neox': 1372, 'n_words': 345}