<commit_before>/**
 *
 *  __         ______     __   __     ______     ______     ______
 * /\ \       /\  __ \   /\ "-.\ \   /\  == \   /\  __ \   /\__  _\
 * \ \ \____  \ \  __ \  \ \ \-.  \  \ \  __<   \ \ \/\ \  \/_/\ \/
 *  \ \_____\  \ \_\ \_\  \ \_\\"\_\  \ \_____\  \ \_____\    \ \_\
 *   \/_____/   \/_/\/_/   \/_/ \/_/   \/_____/   \/_____/     \/_/
 *
 *
 *                 LANBotX, a botkit-powered LANBot
 */

import Botkit from 'botkit';
import redis from 'botkit/lib/storage/redis_storage';
import fs from 'fs';
import Path from 'path';

/**
 * Initialize botkit
 */
const storage = redis({
  namespace: 'lanbot',
  methods: ['teams', 'users', 'channels', 'responses', 'karma'],
});

const controller = Botkit.slackbot({
  debug: false,
  storage: storage,
});

controller.spawn({
  token: process.env.token
}).startRTM((err) => {
  if (err) {
    throw new Error(err);
  }
});

/**
 * Determine if bot is running
 */
controller.hears(
  'ping',
  ['direct_message','direct_mention','mention'],
  (bot,message) => {
    bot.reply(message, 'PONG');
  }
);

/**
 * Initalize scripts
 */
for(const file of fs.readdirSync('./src/')) {
  const script = require('./src/' + file).default;
  new script(controller);<commit_msg>Don't stop loading on bad script<commit_after>/**
 *
 *  __         ______     __   __     ______     ______     ______
 * /\ \       /\  __ \   /\ "-.\ \   /\  == \   /\  __ \   /\__  _\
 * \ \ \____  \ \  __ \  \ \ \-.  \  \ \  __<   \ \ \/\ \  \/_/\ \/
 *  \ \_____\  \ \_\ \_\  \ \_\\"\_\  \ \_____\  \ \_____\    \ \_\
 *   \/_____/   \/_/\/_/   \/_/ \/_/   \/_____/   \/_____/     \/_/
 *
 *
 *                 LANBotX, a botkit-powered LANBot
 */

import Botkit from 'botkit';
import redis from 'botkit/lib/storage/redis_storage';
import fs from 'fs';
import Path from 'path';

/**
 * Initialize botkit
 */
const storage = redis({
  namespace: 'lanbot',
  methods: ['teams', 'users', 'channels', 'responses', 'karma'],
});

const controller = Botkit.slackbot({
  debug: false,
  storage: storage,
});

controller.spawn({
  token: process.env.token
}).startRTM((err) => {
  if (err) {
    throw new Error(err);
  }
});

/**
 * Determine if bot is running
 */
controller.hears(
  'ping',
  ['direct_message','direct_mention','mention'],
  (bot,message) => {
    bot.reply(message, 'PONG');
  }
);

/**
 * Initalize scripts
 */
for(const file of fs.readdirSync('./src/')) {
  if (Path.extname(file) !== '.js') {
    continue;
  }

  try {
    const script = require('./src/' + file).default;
    new script(controller);
  } catch (e) {
    console.error(`Unable to load ${file}: ${e.stack}`);
  }
{'fraction_non_alphanumeric': 0.21973434535104364, 'fraction_numerical': 0.0, 'mean_word_length': 1.8344086021505377, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '4270583', 'n_tokens_mistral': 1019, 'n_tokens_neox': 985, 'n_words': 162}