<commit_before>package plugins

import (
	"fmt"
	"regexp"
	"strings"
	"time"

	"github.com/matrix-org/gomatrix"
)

// Ban responds to ban messages
type Ban struct {
}

// Descr returns a description
func (h *Ban) Descr() string {
	return "Ban a list of users."
}

// Re matches "ban:" in a given string
func (h *Ban) Re() string {
	return `(?i)^ban: (.*)$`
}

// Match determines if we should execute Ban
func (h *Ban) Match(_, msg string) bool {
	re := regexp.MustCompile(h.Re())
	return re.MatchString(msg)
}

// SetStore we don't need a store, so just return
func (h *Ban) SetStore(_ PluginStore) {}

// Process does the heavy lifting
func (h *Ban) Process(from, msg string) string {
	return ""
}

// RespondText to botsnack events
func (h *Ban) RespondText(c *gomatrix.Client, ev *gomatrix.Event, user, post string) error {
	switch ev.Sender {
	case "@qbit:tapenet.org":
		speed := 5
		re := regexp.MustCompile(h.Re())
		bans := strings.Split(re.ReplaceAllString(post, "$1"), " ")

		SendText(c, ev.RoomID, fmt.Sprintf("Banning %d users with %d seconds inbetween bans.", len(bans), speed))
		for _, ban := range bans {
			st := fmt.Sprintf("hammer ban ob user %s spam", ban)
			SendText(c, ev.RoomID, st)
			time.Sleep(time.Second * time.Duration(speed))
		}
	}
	return nil
}

// Name Ban
func (h *Ban) Name() string {
	return "Ban"
}<commit_msg>let mcchunkie do other things<commit_after>package plugins

import (
	"fmt"
	"regexp"
	"strings"
	"time"

	"github.com/matrix-org/gomatrix"
)

// Ban responds to ban messages
type Ban struct {
}

// Descr returns a description
func (h *Ban) Descr() string {
	return "Ban a list of users."
}

// Re matches "ban:" in a given string
func (h *Ban) Re() string {
	return `(?i)^ban: (.*)$`
}

// Match determines if we should execute Ban
func (h *Ban) Match(_, msg string) bool {
	re := regexp.MustCompile(h.Re())
	return re.MatchString(msg)
}

// SetStore we don't need a store, so just return
func (h *Ban) SetStore(_ PluginStore) {}

// Process does the heavy lifting
func (h *Ban) Process(from, msg string) string {
	return ""
}

// RespondText to botsnack events
func (h *Ban) RespondText(c *gomatrix.Client, ev *gomatrix.Event, user, post string) error {
	switch ev.Sender {
	case "@qbit:tapenet.org":
		speed := 5
		re := regexp.MustCompile(h.Re())
		bans := strings.Split(re.ReplaceAllString(post, "$1"), " ")

		go func() {
			SendText(c, ev.RoomID, fmt.Sprintf("Banning %d users with %d seconds inbetween bans.", len(bans), speed))
			for _, ban := range bans {
				st := fmt.Sprintf("hammer ban ob user %s spam", ban)
				SendText(c, ev.RoomID, st)
				time.Sleep(time.Second * time.Duration(speed))
			}
			SendText(c, ev.RoomID, "Done banning.")
		}()
	}
	return nil
}

// Name Ban
func (h *Ban) Name() string {
	return "Ban"
}
{'fraction_non_alphanumeric': 0.15439856373429084, 'fraction_numerical': 0.001436265709156194, 'mean_word_length': 3.674496644295302, 'pattern_counts': {'":': 2, '<': 3, '<?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': '3253252', 'n_tokens_mistral': 1083, 'n_tokens_neox': 994, 'n_words': 322}