<commit_before>
package commands

import (
  "jarvis/service"
  "jarvis/util"
  "jarvis/ws"
  "time"
)

type Exec struct {}

func NewExec() Exec {
  return Exec{}
}

func (c Exec) Name() string {
  return "exec"
}

func (c Exec) Description() string {
  return "provides a containerized, 'safe' environment to execute arbitrary code."
}

func (c Exec) Examples() []string {
  return []string{
    "jarvis exec python print(1+1)",
    "jarvis exec js console.log('hi there')",
  }
}

func (c Exec) OtherDocs() []util.HelpTopic {
  return []util.HelpTopic{}
}

func (c Exec) SubCommands() []util.SubCommand {
  return []util.SubCommand{
    util.NewSubCommand("^jarvis exec python (?P<command>.+)$", c.Python),
  }
}

func (c Exec) Python(m util.IncomingSlackMessage, r util.Regex) {
  command := r.SubExpression(m.Text, 0)
  result, err := service.Docker{}.RunPythonInContainer(command, 10 * time.Second)
  if result[len(result)-1] == '\n' {
    result = result[:len(result)-1]
  }
  if err != nil {
    ws.SendMessage(err.Error(), m.Channel)
  } else {
    msg := "Result:\n```"
    msg += result + "\n```"
    ws.SendMessage(msg, m.Channel)
  }
}<commit_msg>Fixed stringlength bug<commit_after>
package commands

import (
  "jarvis/service"
  "jarvis/util"
  "jarvis/ws"
  "time"
)

type Exec struct {}

func NewExec() Exec {
  return Exec{}
}

func (c Exec) Name() string {
  return "exec"
}

func (c Exec) Description() string {
  return "provides a containerized, 'safe' environment to execute arbitrary code."
}

func (c Exec) Examples() []string {
  return []string{
    "jarvis exec python print(1+1)",
    "jarvis exec js console.log('hi there')",
  }
}

func (c Exec) OtherDocs() []util.HelpTopic {
  return []util.HelpTopic{}
}

func (c Exec) SubCommands() []util.SubCommand {
  return []util.SubCommand{
    util.NewSubCommand("^jarvis exec python (?P<command>.+)$", c.Python),
  }
}

func (c Exec) Python(m util.IncomingSlackMessage, r util.Regex) {
  command := r.SubExpression(m.Text, 0)
  result, err := service.Docker{}.RunPythonInContainer(command, 10 * time.Second)
  if len(result) > 0 {
    if result[len(result)-1] == '\n' {
      result = result[:len(result)-1]
    }
  }
  if err != nil {
    ws.SendMessage(err.Error(), m.Channel)
  } else {
    msg := "Result:\n```"
    msg += result + "\n```"
    ws.SendMessage(msg, m.Channel)
  }
}
{'fraction_non_alphanumeric': 0.17076271186440678, 'fraction_numerical': 0.006355932203389831, 'mean_word_length': 3.6023391812865495, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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': '2238885', 'n_tokens_mistral': 880, 'n_tokens_neox': 843, 'n_words': 217}