<commit_before>package modules

import (
	"regexp"

	"github.com/pajbot/pajbot2/pkg"
	mbase "github.com/pajbot/pajbot2/pkg/modules/base"
	"github.com/pajbot/pajbot2/pkg/twitchactions"
)

func init() {
	Register("banned_names", func() pkg.ModuleSpec {
		badUsernames := []*regexp.Regexp{
			regexp.MustCompile(`tos_is_trash\d+`),
			regexp.MustCompile(`trash_is_the_tos\d+`),
			regexp.MustCompile(`terms_of_service_uncool\d+`),
			regexp.MustCompile(`tos_i_love_mods_no_toxic\d+`),
			regexp.MustCompile(`^kemper.+`),
			regexp.MustCompile(`^pudele\d+`),
			regexp.MustCompile(`^ninjal0ver\d+`),
			regexp.MustCompile(`^trihard_account_\d+`),
			regexp.MustCompile(`^h[il1]erot[il1]tan.+`),
		}

		return &Spec{
			id:   "banned_names",
			name: "Banned names",
			maker: func(b *mbase.Base) pkg.Module {
				return newBannedNames(b, badUsernames)
			},

			enabledByDefault: false,
		}
	})
}

type bannedNames struct {
	mbase.Base

	badUsernames []*regexp.Regexp
}

func newBannedNames(b *mbase.Base, badUsernames []*regexp.Regexp) pkg.Module {
	return &bannedNames{
		Base: *b,
	}
}

func (m bannedNames) OnMessage(event pkg.MessageEvent) pkg.Actions {
	user := event.User

	usernameBytes := []byte(user.GetName())
	for _, badUsername := range m.badUsernames {
		if badUsername.Match(usernameBytes) {
			actions := &twitchactions.Actions{}
			actions.Ban(user).SetReason("Ban evasion")
			return actions
		}
	}

	return nil
}<commit_msg>fix unused argument in banned names module<commit_after>package modules

import (
	"regexp"

	"github.com/pajbot/pajbot2/pkg"
	mbase "github.com/pajbot/pajbot2/pkg/modules/base"
	"github.com/pajbot/pajbot2/pkg/twitchactions"
)

func init() {
	Register("banned_names", func() pkg.ModuleSpec {
		badUsernames := []*regexp.Regexp{
			regexp.MustCompile(`tos_is_trash\d+`),
			regexp.MustCompile(`trash_is_the_tos\d+`),
			regexp.MustCompile(`terms_of_service_uncool\d+`),
			regexp.MustCompile(`tos_i_love_mods_no_toxic\d+`),
			regexp.MustCompile(`^kemper.+`),
			regexp.MustCompile(`^pudele\d+`),
			regexp.MustCompile(`^ninjal0ver\d+`),
			regexp.MustCompile(`^trihard_account_\d+`),
			regexp.MustCompile(`^h[il1]erot[il1]tan.+`),
		}

		return &Spec{
			id:   "banned_names",
			name: "Banned names",
			maker: func(b *mbase.Base) pkg.Module {
				return newBannedNames(b, badUsernames)
			},

			enabledByDefault: false,
		}
	})
}

type bannedNames struct {
	mbase.Base

	badUsernames []*regexp.Regexp
}

func newBannedNames(b *mbase.Base, badUsernames []*regexp.Regexp) pkg.Module {
	return &bannedNames{
		Base: *b,

		badUsernames: badUsernames,
	}
}

func (m bannedNames) OnMessage(event pkg.MessageEvent) pkg.Actions {
	user := event.User

	usernameBytes := []byte(user.GetName())
	for _, badUsername := range m.badUsernames {
		if badUsername.Match(usernameBytes) {
			actions := &twitchactions.Actions{}
			actions.Ban(user).SetReason("Ban evasion")
			return actions
		}
	}

	return nil
}
{'fraction_non_alphanumeric': 0.15452688904016337, 'fraction_numerical': 0.0040844111640571815, 'mean_word_length': 4.651923076923077, 'pattern_counts': {'":': 0, '<': 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': '5366745', 'n_tokens_mistral': 1289, 'n_tokens_neox': 1165, 'n_words': 168}