<commit_before>package connectors

import (
	"bufio"
	"bytes"
	"errors"
	"log"

	"github.com/masterzen/winrm"
	"github.com/projectjane/jane/models"
	"github.com/projectjane/jane/parse"
)

//WinRM Struct representing a WinRM Connector
type WinRM struct {
	Client *winrm.Client
}

//Listen Listen not implemented for WinRM
func (x WinRM) Listen(commandMsgs chan<- models.Message, connector models.Connector) {
	defer Recovery(connector)
}

//Command Standard command parser
func (x WinRM) Command(message models.Message, publishMsgs chan<- models.Message, connector models.Connector) {
	if match, tokens := parse.Match("winrm*", message.In.Text); match {
		message.Out.Text = callWolfram(tokens["*"], connector.Key)
		publishMsgs <- message
	}

	if x.Client == nil {
		log.Println("Client is nil. Connecting...")

		var err error

		endpoint := winrm.NewEndpoint(connector.Server, 5985, false, false, nil, nil, nil, 0)
		x.Client, err = winrm.NewClient(endpoint, connector.Login, connector.Pass)
		if err != nil {
			log.Println("Error connecting to endpoint:", err)
		}
	}

	out, err := x.sendCommand("ipconfig")
	if err != nil {
		log.Println("Error sending command:", err)
		message.Out.Text = "Error processing command: "
		message.Out.Status = "FAIL"
	} else {
		message.Out.Text = out
		message.Out.Status = "SUCCESS"
	}

	publishMsgs <- message<commit_msg>Cleaning up the command input<commit_after>package connectors

import (
	"bufio"
	"bytes"
	"errors"
	"log"

	"github.com/masterzen/winrm"
	"github.com/projectjane/jane/models"
	"github.com/projectjane/jane/parse"
)

//WinRM Struct representing a WinRM Connector
type WinRM struct {
	Client *winrm.Client
}

//Listen Listen not implemented for WinRM
func (x WinRM) Listen(commandMsgs chan<- models.Message, connector models.Connector) {
	defer Recovery(connector)
}

//Command Standard command parser
func (x WinRM) Command(message models.Message, publishMsgs chan<- models.Message, connector models.Connector) {
	if match, tokens := parse.Match("winrm*", message.In.Text); match {
		command := tokens["*"]

		if x.Client == nil {
			log.Println("Client is nil. Connecting...")

			var err error

			endpoint := winrm.NewEndpoint(connector.Server, 5985, false, false, nil, nil, nil, 0)
			x.Client, err = winrm.NewClient(endpoint, connector.Login, connector.Pass)
			if err != nil {
				log.Println("Error connecting to endpoint:", err)
			}
		}

		out, err := x.sendCommand(command)
		if err != nil {
			log.Println("Error sending command:", err)
			message.Out.Text = "Error processing command: "
			message.Out.Status = "FAIL"
		} else {
			message.Out.Text = out
			message.Out.Status = "SUCCESS"
		}

		publishMsgs <- message
	}
{'fraction_non_alphanumeric': 0.13330857779428146, 'fraction_numerical': 0.003713330857779428, 'mean_word_length': 4.026119402985074, 'pattern_counts': {'":': 0, '<': 10, '<?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': '1733740', 'n_tokens_mistral': 970, 'n_tokens_neox': 880, 'n_words': 234}