<commit_before>'use strict'

const client   = require('cheerio-httpcli');
const request  = require('request');
const settings = require('./settings');


const Usen = function() {
  this.param = {
    npband: 'C',
    npch  : '26',
    nppage: 'yes',
    _     : ''
  };
  this.nowPlaying  = '';
  this.botName     = settings.BOT_NAME;
  this.webhookUrl  = settings.WEB_HOOK_URL;
  this.channelName = '';
};

Usen.prototype = {

  postNowPlaying: function() {

    this.param._ = new Date().getTime();

    client.fetch('http://music.usen.com/usencms/search_nowplay1.php', this.param)
    .then((result) => {
      return result.$('.np-now li').text().replace(/[ａ-ｚＡ-Ｚ０-９＝！？＄＋＊％＆]/g, (s) => {
        return String.fromCharCode(s.charCodeAt(0) - 0xFEE0);
      }).replace(/　/g, ' ').replace(/’/g, "'").replace(/－/g, '-');
    })
    .then((np) => {
      if (np !== this.nowPlaying) {
        const form = {
          text    : np,
          username: this.channelName
        };
        const options = {
          url : this.webhookUrl,
          form: 'payload=' + JSON.stringify(form),
          json: true
        };
        request.post(options, (error, res, body) => {
          console.log(body);
          this.nowPlaying = np;
        });
      }
    });
  },

  setBand: function(band) {
    this.param.npband = band;
  },

  getBand: function() {
    return this.param.npband;
  },

  setChannel: function(channel) {
    this.param.npch = channel;
  },

  getChannel: function() {
    return this.param.npch;
  },

  getNowPlaying: function() {
    return this.nowPlaying;
  },

  getChannelName: function() {
    return this.channelName;
  },

  getChannelTitle: function() {
    client.fetch('http://music.usen.com/channel/' + this.param.npband + this.param.npch + '/')
    .then((result) => {
      return result.$('.detail-title > h2').text();
    })
    .then((title) => {
      this.channelName = title;
      const form = {
        text    : title,
        username: this.botName
      };
      const options = {
        url : this.webhookUrl,
        form: 'payload=' + JSON.stringify(form),
        json: true
      };
      request.post(options, (error, res, body) => {
        console.log(body);
      });
    })
  }
}

module.exports = Usen;
<commit_msg>add escape<commit_after>'use strict'

const client   = require('cheerio-httpcli');
const request  = require('request');
const settings = require('./settings');


const Usen = function() {
  this.param = {
    npband: 'C',
    npch  : '26',
    nppage: 'yes',
    _     : ''
  };
  this.nowPlaying  = '';
  this.botName     = settings.BOT_NAME;
  this.webhookUrl  = settings.WEB_HOOK_URL;
  this.channelName = '';
};

Usen.prototype = {

  postNowPlaying: function() {

    this.param._ = new Date().getTime();

    client.fetch('http://music.usen.com/usencms/search_nowplay1.php', this.param)
    .then((result) => {
      return result.$('.np-now li').text().replace(/[ａ-ｚＡ-Ｚ０-９＝！？＄＋＊％＆]/g, (s) => {
        return String.fromCharCode(s.charCodeAt(0) - 0xFEE0);
      }).replace(/　/g, ' ').replace(/’/g, "'").replace(/－/g, '-');
    })
    .then((np) => {
      if (np !== this.nowPlaying) {
        const form = {
          text    : encodeURIComponent(np),
          username: this.channelName
        };
        const options = {
          url : this.webhookUrl,
          form: 'payload=' + JSON.stringify(form),
          json: true
        };
        request.post(options, (error, res, body) => {
          console.log(body);
          this.nowPlaying = np;
        });
      }
    });
  },

  setBand: function(band) {
    this.param.npband = band;
  },

  getBand: function() {
    return this.param.npband;
  },

  setChannel: function(channel) {
    this.param.npch = channel;
  },

  getChannel: function() {
    return this.param.npch;
  },

  getNowPlaying: function() {
    return this.nowPlaying;
  },

  getChannelName: function() {
    return this.channelName;
  },

  getChannelTitle: function() {
    client.fetch('http://music.usen.com/channel/' + this.param.npband + this.param.npch + '/')
    .then((result) => {
      return result.$('.detail-title > h2').text();
    })
    .then((title) => {
      this.channelName = title;
      const form = {
        text    : title,
        username: this.botName
      };
      const options = {
        url : this.webhookUrl,
        form: 'payload=' + JSON.stringify(form),
        json: true
      };
      request.post(options, (error, res, body) => {
        console.log(body);
      });
    })
  }
}

module.exports = Usen;

{'fraction_non_alphanumeric': 0.1793918179829359, 'fraction_numerical': 0.003937869175235178, 'mean_word_length': 2.157458563535912, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '268381', 'n_tokens_mistral': 1630, 'n_tokens_neox': 1567, 'n_words': 263}