<commit_before>package connectors

import (
	"log"
	"strings"
	"github.com/projectjane/jane/models"
  "gopkg.in/redis.v3"
)

type Redis struct {
}

type Environment struct {
	Address string
	Password string
	DB int64
}

func (x Redis) Listen(commandMsgs chan<- models.Message, connector models.Connector) {
	defer Recovery(connector)
	return
}

func (x Redis) Command(message models.Message, publishMsgs chan<- models.Message, connector models.Connector) {
	if message.In.Process {
		for _, c := range connector.Commands {
			if strings.HasPrefix(strings.ToLower(message.In.Text), strings.ToLower(c.Match)) {
				environment := Environment {
					Address: connector.Server,
					Password: <PASSWORD>,
					DB: 0,
				}

				status := FlushDb(environment)
				log.Println(status.String())
				message.Out.Text = status.String()
				publishMsgs <- message
				return
			}
		}
	}
}

func (x Redis) Publish(connector models.Connector, message models.Message, target string) {
	return
}

func (x Redis) Help(connector models.Connector) (help string) {
	help += "jane flushdb <environment> - flushes the environments redis db\n"
	return help
}

func NewClient(environment Environment) *redis.Client {
  return redis.NewClient(&redis.Options{
        Addr:     environment.Address,
        Password: environment.Password,
        DB:       environment.DB,
  })
}

func FlushDb(environment Environment) *redis.StatusCmd {
	client := NewClient(environment)
  defer client.Close()

  return client.FlushDb()
}<commit_msg>Adding servername output to flush message<commit_after>package connectors

import (
	"log"
	"strings"
	"fmt"
	"github.com/projectjane/jane/models"
  "gopkg.in/redis.v3"
)

type Redis struct {
}

type Environment struct {
	Address string
	Password string
	DB int64
}

func (x Redis) Listen(commandMsgs chan<- models.Message, connector models.Connector) {
	defer Recovery(connector)
	return
}

func (x Redis) Command(message models.Message, publishMsgs chan<- models.Message, connector models.Connector) {
	if message.In.Process {
		for _, c := range connector.Commands {
			if strings.HasPrefix(strings.ToLower(message.In.Text), strings.ToLower(c.Match)) {
				environment := Environment {
					Address: connector.Server,
					Password: <PASSWORD>,
					DB: 0,
				}

				status := FlushDb(environment)
				log.Println(status.String())
				message.Out.Text = fmt.Sprintf("Redis Server: %s\nStatus:%s", connector.Server, status.String())
				publishMsgs <- message
				return
			}
		}
	}
}

func (x Redis) Publish(connector models.Connector, message models.Message, target string) {
	return
}

func (x Redis) Help(connector models.Connector) (help string) {
	help += "jane flushdb <environment> - flushes the environments redis db\n"
	return help
}

func NewClient(environment Environment) *redis.Client {
  return redis.NewClient(&redis.Options{
        Addr:     environment.Address,
        Password: environment.Password,
        DB:       environment.DB,
  })
}

func FlushDb(environment Environment) *redis.StatusCmd {
	client := NewClient(environment)
  defer client.Close()

  return client.FlushDb()
}
{'fraction_non_alphanumeric': 0.11445976274446938, 'fraction_numerical': 0.0025649246553382495, 'mean_word_length': 3.82225656877898, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 7, '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': '3666293', 'n_tokens_mistral': 1088, 'n_tokens_neox': 982, 'n_words': 240}