<commit_before>var path        = require('path')
var fs          = require('fs')
var op          = require('object-path')
var request     = require('request')
var SlackBot    = require('slackbots')
var SlackUp     = require('node-slack-upload')


// TODO: Token for 'noise' has to be read from Entu screen
var token = '<KEY>'

// TODO: Token for 'alerts' webhook has to be read from Entu customer
var token = '<KEY>'

var c = require('./c.js')

var jt = function() {
    var jt = require('./gintonic.json')
    return jt[Math.floor(Math.random()*jt.length)]
}


var slackbot_settings = {
    token: token,
    // name: 'noise'
}
try {
    var slackbot = new SlackBot(slackbot_settings)
} catch (err) {
    c.log.error('Failed to init slackbot.')
    c.log.error(err)
    c.restart()
}

var isWin = /^win/.test(process.platform);


slackbot.chatter = function(message, channel) {
    if (!channel) { channel = c.slackChannels.chat }
    // c.log.info('XXXXXXX', channel, message)
    // var datestring = new Date().toISOString().replace(/T/, ' ').replace(/:/g, '-').replace(/\..+/, '')
    datestring = ''
    slackbot.postMessageToChannel(channel, datestring + ' *' + c.__SCREEN_ID + '* ' + message, {as_user: true})
}



function captureScreenshot() {
    c.log.info('Start ss')
    c.player_window.capturePage(function(buffer) {
        c.log.info('Got ss')
        var datestring = new Date().toISOString().replace(/T/, ' ').replace(/:/g, '-').replace(/\..+/, '')
        var screenshot_path = path.join(c.__LOG_DIR, c.__SCREEN_ID + '_' + datestring + '.png'
        var writer = fs.createWriteStream(screenshot_path)
        if (writer.write(buffer) === false) {
            writer.once('drain', function() {writer.write(buffer)})
        }
        writer.close()
        // callback(screenshot_path)
        var params_o = {
            filetype: 'post',
            filename: c.__SCREEN_ID + '.png',
            title: c.__SCREEN_ID + '.png',
            channels: '%23logs',
            username: 'noise',
            as_user: 'true',
            filetype: 'image'
        }
        var params_a = []
        for (var key in params_o) {
            params_a.push(key + '=' + params_o[key])
        }
        var params = params_a.join('&')
        var endpoint = 'https://slack.com/api/files.upload?token=' + token + '&' + params<commit_msg>hotfix<commit_after>var path        = require('path')
var fs          = require('fs')
var op          = require('object-path')
var request     = require('request')
var SlackBot    = require('slackbots')
var SlackUp     = require('node-slack-upload')


// TODO: Token for 'noise' has to be read from Entu screen
var token = '<KEY>'

// TODO: Token for 'alerts' webhook has to be read from Entu customer
var token = '<KEY>'

var c = require('./c.js')

var jt = function() {
    var jt = require('./gintonic.json')
    return jt[Math.floor(Math.random()*jt.length)]
}


var slackbot_settings = {
    token: token,
    // name: 'noise'
}
try {
    var slackbot = new SlackBot(slackbot_settings)
} catch (err) {
    c.log.error('Failed to init slackbot.')
    c.log.error(err)
    c.restart()
}

var isWin = /^win/.test(process.platform);


slackbot.chatter = function(message, channel) {
    if (!channel) { channel = c.slackChannels.chat }
    // c.log.info('XXXXXXX', channel, message)
    // var datestring = new Date().toISOString().replace(/T/, ' ').replace(/:/g, '-').replace(/\..+/, '')
    datestring = ''
    slackbot.postMessageToChannel(channel, datestring + ' *' + c.__SCREEN_ID + '* ' + message, {as_user: true})
}



function captureScreenshot() {
    c.log.info('Start ss')
    c.player_window.capturePage(function(buffer) {
        c.log.info('Got ss')
        var datestring = new Date().toISOString().replace(/T/, ' ').replace(/:/g, '-').replace(/\..+/, '')
        var screenshot_path = path.join(c.__LOG_DIR, c.__SCREEN_ID + '_' + datestring + '.png')
        var writer = fs.createWriteStream(screenshot_path)
        if (writer.write(buffer) === false) {
            writer.once('drain', function() {writer.write(buffer)})
        }
        writer.close()
        // callback(screenshot_path)
        var params_o = {
            filetype: 'post',
            filename: c.__SCREEN_ID + '.png',
            title: c.__SCREEN_ID + '.png',
            channels: '%23logs',
            username: 'noise',
            as_user: 'true',
            filetype: 'image'
        }
        var params_a = []
        for (var key in params_o) {
            params_a.push(key + '=' + params_o[key])
        }
        var params = params_a.join('&')
        var endpoint = 'https://slack.com/api/files.upload?token=' + token + '&' + params
{'fraction_non_alphanumeric': 0.16993603411513858, 'fraction_numerical': 0.0008528784648187633, 'mean_word_length': 2.451802796173657, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '7083725', 'n_tokens_mistral': 1580, 'n_tokens_neox': 1545, 'n_words': 335}