<commit_before><commit_msg>Initial commit with some POC code<commit_after>nconf = require("nconf")
deployments = require './data/deployments.json'

cwd = process.cwd()
DEFAULTS_FILE = "#{__dirname}/data/defaults.json"

nconf.argv()
    .env()
    .file('defaults', DEFAULTS_FILE)

sanity_check_args = (msg) ->
  required_args = [
  ]

  for arg in required_args
    if !nconf.get(arg)
      buf = "#hubot-grafana-annotations is not properly configured. #{arg} is not set."
      msg.reply buf
      return false

  return true

help = (msg) ->
  commands = [
    "grafana-annotations show deployments"
    "grafana-annotations help"
  ]
  buf = ""
  for command in commands
    buf += "#{command}\n"

  msg.reply buf

deployment_event = (msg, deployment) -> 
  text = msg.message.text
  msg.reply "#{deployment}: #{text}"

module.exports = (robot) ->

  robot.hear /grafana-annotations help/i, (msg) ->
    help(msg)

  robot.hear /grafana-annotations show deployments/i, (msg) ->
    msg.reply triggers.join('\n')

  for deployment in deployments
    regex = new RegExp "(#{deployment})", 'i'
    robot.hear regex, (msg) ->
      if !sanity_check_args(msg)
        return
      deployment_event(msg, msg.match[1])
{'fraction_non_alphanumeric': 0.14085667215815487, 'fraction_numerical': 0.0008237232289950577, 'mean_word_length': 3.189655172413793, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '3811428', 'n_tokens_mistral': 420, 'n_tokens_neox': 417, 'n_words': 99}