<commit_before>
'use strict'

const _ = require('lodash')
const fs = require('fs')
const config = require('../config')
const scriptures = require("../data/scriptures")

function scriptureCount(scriptures) {
	var scripture
	var count = 0

	for(scripture in scriptures) {
		count++
	}
	return count
}

function getScripture(scriptures) {
	var num
	num = Math.floor(Math.random() * scriptureCount(scriptures))
	console.log(num)

	var scripture = scriptures[num]
	console.log(scripture);
	
	return scripture.passage + "\n -" + scripture.location
}

const msgDefaults = {
  response_type: 'in_channel',
  username: 'Stubot',
  icon_emoji: config('ICON_EMOJI')
}

let attachments = [
  {
    title: 'Stubot will retrieve a random scriptural thought for you.',
    color: '#2FA44F',
    text: getScripture(scriptures.scriptures),
    mrkdwn_in: ['text']
  },
]

const handler = (payload, res) => {
  let msg = _.defaults({
    channel: payload.channel_name,
    attachments: attachments
  }, msgDefaults)<commit_msg>Moved attachment into handler constructor.<commit_after>
'use strict'

const _ = require('lodash')
const fs = require('fs')
const config = require('../config')
const scriptures = require("../data/scriptures")

function scriptureCount(scriptures) {
	var scripture
	var count = 0

	for(scripture in scriptures) {
		count++
	}
	return count
}

function getScripture(scriptures) {
	var num
	num = Math.floor(Math.random() * scriptureCount(scriptures))
	console.log(num)

	var scripture = scriptures[num]
	console.log(scripture);
	
	return scripture.passage + "\n -" + scripture.location
}

const msgDefaults = {
  response_type: 'in_channel',
  username: 'Stubot',
  icon_emoji: config('ICON_EMOJI')
}

const handler = (payload, res) => {
	let attachments = [
	  {
		title: 'Stubot will retrieve a random scriptural thought for you.',
		color: '#2FA44F',
		text: getScripture(scriptures.scriptures),
		mrkdwn_in: ['text']
	  },
	]

  let msg = _.defaults({
    channel: payload.channel_name,
    attachments: attachments
  }, msgDefaults)
{'fraction_non_alphanumeric': 0.13264806656877143, 'fraction_numerical': 0.003915810083210965, 'mean_word_length': 4.322916666666667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '326328', 'n_tokens_mistral': 711, 'n_tokens_neox': 677, 'n_words': 165}