<commit_before>const fp = require('lodash/fp')

const logger = require('../logger')
const config = require('../config')
const { leaveNetwork, saveMessage } = require('../rethink/queries')
const { humanizeDelta } = require('../utils')
const { versionText } = require('../version')
const { ircClient, ctx } = require('./index')

const onPing = async () => {
  return 'pong'
}

const onEcho = async ({ params }) => {
  return params
}

const onUptime = async () => {
  if (ctx.connectionTime) {
    return humanizeDelta(new Date() - ctx.connectionTime)
  } else {
    return 0
  }
}

const onVersion = async () => {
  return versionText
}

const onReload = async ({ message }) => {
  if (!fp.includes(message.from, config.irc.admins)) {
    return
  }

  logger.info(`!reload requested by ${message.from}, exiting...`)

  const now = new Date()

  const users = await leaveNetwork(ircClient.user.nick)
  for (const user of users) {
    await saveMessage({
      kind: 'quit',
      timestamp: now,
      from: user.nick,
      to: user.channel,
      text: '',
    })
  }

  process.exit(0)
}

const commandMap = {
  ping: onPing,
  echo: onEcho,
  uptime: onUptime,
  version: onVersion,
  reload: onReload,
}<commit_msg>Remove !reload<commit_after>const fp = require('lodash/fp')

const logger = require('../logger')
const config = require('../config')
const { leaveNetwork, saveMessage } = require('../rethink/queries')
const { humanizeDelta } = require('../utils')
const { versionText } = require('../version')
const { ircClient, ctx } = require('./index')

const onPing = async () => {
  return 'pong'
}

const onEcho = async ({ params }) => {
  return params
}

const onUptime = async () => {
  if (ctx.connectionTime) {
    return humanizeDelta(new Date() - ctx.connectionTime)
  } else {
    return 0
  }
}

const onVersion = async () => {
  return versionText
}

const commandMap = {
  ping: onPing,
  echo: onEcho,
  uptime: onUptime,
  version: onVersion,
}
{'fraction_non_alphanumeric': 0.1623409669211196, 'fraction_numerical': 0.0015267175572519084, 'mean_word_length': 3.320879120879121, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '2614273', 'n_tokens_mistral': 666, 'n_tokens_neox': 647, 'n_words': 163}