<commit_before>package connectors

import (
	"bytes"
	"log"
	"os/exec"
	"strconv"
	"strings"
	"time"

	"github.com/projectjane/jane/models"
	"github.com/projectjane/jane/parse"
	"github.com/robfig/cron"
	"golang.org/x/crypto/ssh"
)

//Exec struct
type Exec struct {
}

//Listen function
func (x Exec) Listen(commandMsgs chan<- models.Message, connector models.Connector) {
	defer Recovery(connector)
	for _, command := range connector.Commands {
		if command.RunCheck {
			if connector.Debug {
				log.Print("Starting Listener for " + connector.ID + " " + command.Name)
			}
			go check(commandMsgs, command, connector)
		}
		if command.Schedule != "" {
			if connector.Debug {
				log.Print("Scheduling Listener for " + connector.ID + " " + command.Name + " @ " + command.Schedule)
			}
			schedule(commandMsgs, command, connector)
		}
	}
}

//Command function
func (x Exec) Command(message models.Message, publishMsgs chan<- models.Message, connector models.Connector) {
	for _, command := range connector.Commands {
		if match, tokens := parse.Match(command.Match, message.In.Text); match {
			args := parse.Substitute(command.Args, tokens)
			tokens["STDOUT"] = callCmd(command.Cmd, args, connector)
			var color = "NONE"
			var match = false
			if match, _ = parse.Match(command.Green, tokens["STDOUT"]); match {
				color = "SUCCESS"
			}
			if match, _ = parse.Match(command.Yellow, tokens["STDOUT"]); match {
				color = "WARN"
			}
			if match, _ = parse.Match(command.Red, tokens["STDOUT"]); match {
				color = "FAIL"
			}
			message.In.Tags = parse.TagAppend(message.In.Tags, connector.Tags+","+command.Tags)
			message.Out.Text = connector.ID + " " + command.Name
			message.Out.Detail = parse.Substitute(command.Output, tokens)
			message.Out.Status = color
			publishMsgs <- message
		}
	}
}

//Publish fucntion
func (x Exec) Publish(publishMsgs <-chan models.Message, connector models.Connector) {<commit_msg>trying fix for rogue Jane answers<commit_after>package connectors

import (
	"bytes"
	"log"
	"os/exec"
	"strconv"
	"strings"
	"time"

	"github.com/projectjane/jane/models"
	"github.com/projectjane/jane/parse"
	"github.com/robfig/cron"
	"golang.org/x/crypto/ssh"
)

//Exec struct
type Exec struct {
}

//Listen function
func (x Exec) Listen(commandMsgs chan<- models.Message, connector models.Connector) {
	defer Recovery(connector)
	for _, command := range connector.Commands {
		if command.RunCheck {
			if connector.Debug {
				log.Print("Starting Listener for " + connector.ID + " " + command.Name)
			}
			go check(commandMsgs, command, connector)
		}
		if command.Schedule != "" {
			if connector.Debug {
				log.Print("Scheduling Listener for " + connector.ID + " " + command.Name + " @ " + command.Schedule)
			}
			schedule(commandMsgs, command, connector)
		}
	}
}

//Command function
func (x Exec) Command(message models.Message, publishMsgs chan<- models.Message, connector models.Connector) {
	for _, command := range connector.Commands {
		if command.Match != "" {
			if match, tokens := parse.Match(command.Match, message.In.Text); match {
				args := parse.Substitute(command.Args, tokens)
				tokens["STDOUT"] = callCmd(command.Cmd, args, connector)
				var color = "NONE"
				var match = false
				if match, _ = parse.Match(command.Green, tokens["STDOUT"]); match {
					color = "SUCCESS"
				}
				if match, _ = parse.Match(command.Yellow, tokens["STDOUT"]); match {
					color = "WARN"
				}
				if match, _ = parse.Match(command.Red, tokens["STDOUT"]); match {
					color = "FAIL"
				}
				message.In.Tags = parse.TagAppend(message.In.Tags, connector.Tags+","+command.Tags)
				message.Out.Text = connector.ID + " " + command.Name
				message.Out.Detail = parse.Substitute(command.Output, tokens)
				message.Out.Status = color
				publishMsgs <- message
			}
		}
	}
}

//Publish fucntion
func (x Exec) Publish(publishMsgs <-chan models.Message, connector models.Connector) {
{'fraction_non_alphanumeric': 0.14256567202244325, 'fraction_numerical': 0.0, 'mean_word_length': 3.608695652173913, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, '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': '1502213', 'n_tokens_mistral': 1504, 'n_tokens_neox': 1290, 'n_words': 285}