<commit_before>package bot

import (
	"fmt"
	"os"
	"regexp"
	"runtime/debug"
	"strings"
	"time"
)

const escapeAliases = `*+|^$?\[]{}`
const aliases = `&!;:-%#@~<>/`

func checkPanic(bot *Robot, s string) {
	if r := recover(); r != nil {
		Log(Error, fmt.Sprintf("PANIC from \"%s\": %s\nStack trace:%s", s, r, debug.Stack()))
		bot.Reply(fmt.Sprintf("OUCH! It looks like you found a bug - please ask an admin to check the log and give them this string: \"%s\"", s))
		time.Sleep(2 * time.Second)
		os.Exit(1)
	}
}

func setFormat(format string) MessageFormat {
	switch format {
	case "fixed":
		return Fixed
	default:
		return Variable
	}
}

func updateRegexes() {
	robot.RLock()
	alias := robot.alias
	robot.RUnlock()
	preString := `^(?i:`
	if robot.alias != 0 {
		if strings.ContainsRune(string(escapeAliases), alias) {
			preString += `\` + string(alias) + "|"
		} else {
			preString += string(alias) + "|"
		}
	}
	preString += `@?` + robot.name + `[:,]{0,1}\s*)(.*)$`
	re, err := regexp.Compile(preString)
	if err == nil {
		Log(Debug, "Setting preString regex to", preString)
		robot.Lock()
		robot.preRegex = re
		robot.Unlock()
	} else {
		Log(Error, fmt.Sprintf("Error compiling robot name regex: %s", preString))
	}
	postString := `^([^,@]+),?\s*(?i:@?` + robot.name + `)([.?!])?$`
	re, err = regexp.Compile(postString)
	if err == nil {
		Log(Debug, "Setting postString regex to", postString)
		robot.Lock()
		robot.postRegex = re
		robot.Unlock()
	} else {
		Log(Error, fmt.Sprintf("Error compiling robot name regex: %s", postString))
	}
}
<commit_msg>Remove | from list of aliases<commit_after>package bot

import (
	"fmt"
	"os"
	"regexp"
	"runtime/debug"
	"strings"
	"time"
)

const escapeAliases = `*+^$?\[]{}`
const aliases = `&!;:-%#@~<>/`

func checkPanic(bot *Robot, s string) {
	if r := recover(); r != nil {
		Log(Error, fmt.Sprintf("PANIC from \"%s\": %s\nStack trace:%s", s, r, debug.Stack()))
		bot.Reply(fmt.Sprintf("OUCH! It looks like you found a bug - please ask an admin to check the log and give them this string: \"%s\"", s))
		time.Sleep(2 * time.Second)
		os.Exit(1)
	}
}

func setFormat(format string) MessageFormat {
	switch format {
	case "fixed":
		return Fixed
	default:
		return Variable
	}
}

func updateRegexes() {
	robot.RLock()
	alias := robot.alias
	robot.RUnlock()
	preString := `^(?i:`
	if robot.alias != 0 {
		if strings.ContainsRune(string(escapeAliases), alias) {
			preString += `\` + string(alias) + "|"
		} else {
			preString += string(alias) + "|"
		}
	}
	preString += `@?` + robot.name + `[:,]{0,1}\s*)(.*)$`
	re, err := regexp.Compile(preString)
	if err == nil {
		Log(Debug, "Setting preString regex to", preString)
		robot.Lock()
		robot.preRegex = re
		robot.Unlock()
	} else {
		Log(Error, fmt.Sprintf("Error compiling robot name regex: %s", preString))
	}
	postString := `^([^,@]+),?\s*(?i:@?` + robot.name + `)([.?!])?$`
	re, err = regexp.Compile(postString)
	if err == nil {
		Log(Debug, "Setting postString regex to", postString)
		robot.Lock()
		robot.postRegex = re
		robot.Unlock()
	} else {
		Log(Error, fmt.Sprintf("Error compiling robot name regex: %s", postString))
	}
}

{'fraction_non_alphanumeric': 0.19929958611907037, 'fraction_numerical': 0.003183699458771092, 'mean_word_length': 3.8487654320987654, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 5, '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': '2672652', 'n_tokens_mistral': 1289, 'n_tokens_neox': 1218, 'n_words': 296}