<commit_before>from hashlib import md5, sha256

from speakerlib import niceify_number

import requests

from config import config

from fuzzywuzzy import process

class EventRecorder(object):

    def __init__(self, db):

        self.db = db
        #self.censored_words = self.db.execute('')


    def censor(*args, **kwargs):
        self = args[0]
        args = list(args)
        censored_words = self.db.execute("select word from badwords")
        bad_words = [row["word"] for row in censored_words]

        speech_text = kwargs.get("speech_text", None) or args[1]

        speech_list = speech_text.split(" ")

        for word in speech_list:
            if word.lower() in bad_words or process.extractOne(word, bad_words)[1] > 90:
                speech_text = "You've been naughty."
                break

        if kwargs.get("speech_text", None):
            kwargs["speech_text"] = speech_text
        else:
            args[1] = speech_text

        return tuple(args)[1:], kwargs


    def post_to_slack(self, speech_text, record_utterance=False, **kwargs):
        #Skip plugins
        if speech_text[0] == "!":
            return

        if config.get("slack_url", None) and record_utterance:
            requests.post(config["slack_url"], data=speech_text)

    def record_utterance(self, speech_text, record_utterance=False, event_result=None):
        if not record_utterance:
            return<commit_msg>The new-style plugin routing ignores record_utterance and shouldn't<commit_after>from hashlib import md5, sha256

from speakerlib import niceify_number

import requests

from config import config

from fuzzywuzzy import process

class EventRecorder(object):

    def __init__(self, db):

        self.db = db
        #self.censored_words = self.db.execute('')


    def censor(*args, **kwargs):
        self = args[0]
        args = list(args)
        censored_words = self.db.execute("select word from badwords")
        bad_words = [row["word"] for row in censored_words]

        speech_text = kwargs.get("speech_text", None) or args[1]

        speech_list = speech_text.split(" ")

        for word in speech_list:
            if word.lower() in bad_words or process.extractOne(word, bad_words)[1] > 90:
                speech_text = "You've been naughty."
                break

        if kwargs.get("speech_text", None):
            kwargs["speech_text"] = speech_text
        else:
            args[1] = speech_text

        return tuple(args)[1:], kwargs


    def post_to_slack(self, speech_text, record_utterance=False, **kwargs):
        #Skip plugins
        if speech_text[0] == "!":
            return

        if config.get("slack_url", None) and record_utterance:
            requests.post(config["slack_url"], data=speech_text)

    def record_utterance(self, speech_text, record_utterance=False, event_result=None):
        if not record_utterance or speech_text[0] == "!":
            return
{'fraction_non_alphanumeric': 0.10220713073005093, 'fraction_numerical': 0.008488964346349746, 'mean_word_length': 2.614723926380368, 'pattern_counts': {'":': 3, '<': 3, '<?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': '3487628', 'n_tokens_mistral': 915, 'n_tokens_neox': 859, 'n_words': 222}