<commit_before>import re
from validators import KeywordValidator, Validator

# Arrary of validator actions
validators = []

########################################
# Define Validators
########################################

#############
stop_validator = KeywordValidator('stop')
validators.append(stop_validator)

@stop_validator.set('action')
def validator_action(message):
    print 'STOP messaging for {}'.format(message.contact)
    message.contact.set_status('stopped','Participant sent stop keyword')
    message.text += ' - <NAME>'
    message.contact.send_automated_message(
        send_base='stop',
        send_offset=0,
        group='one-way',
        hiv_messaging=False
    )
    return False

###############
validation_validator = Validator('validation')
validators.append(validation_validator)

@validation_validator.set('check')
def validator_action(message):
    if re.match('^\d{5}$',message.text) and not message.contact.is_validated:
        message.topic = 'validation'
        message.is_related = True
        message.is_viewed = True
        if message.contact.validation_key == message.text.strip():
            message.text = 'Validation Code Correct: ' + message.text
            return True
        else:
            message.text = 'Validation Code Incorrect: ' + message.text
            return False
    return False

@validation_validator.set('action')
def validator_action(message):
    # print 'VALIDATION ACTION for {}'.format(contact)
    message.contact.is_validated = True
    message.contact.save()
    return False # Don't continue validation check  s

###############<commit_msg>fix(validation) send stop message on stop<commit_after>import re
from validators import KeywordValidator, Validator

# Arrary of validator actions
validators = []

########################################
# Define Validators
########################################

#############
stop_validator = KeywordValidator('stop')
validators.append(stop_validator)

@stop_validator.set('action')
def validator_action(message):
    print 'STOP messaging for {}'.format(message.contact)
    message.contact.set_status('stopped','Participant sent stop keyword')
    message.text += ' - <NAME>'
    message.contact.send_automated_message(
        send_base='stop',
        send_offset=0,
        group='one-way',
        hiv_messaging=False,
        control=True
    )
    return False

###############
validation_validator = Validator('validation')
validators.append(validation_validator)

@validation_validator.set('check')
def validator_action(message):
    if re.match('^\d{5}$',message.text) and not message.contact.is_validated:
        message.topic = 'validation'
        message.is_related = True
        message.is_viewed = True
        if message.contact.validation_key == message.text.strip():
            message.text = 'Validation Code Correct: ' + message.text
            return True
        else:
            message.text = 'Validation Code Incorrect: ' + message.text
            return False
    return False

@validation_validator.set('action')
def validator_action(message):
    # print 'VALIDATION ACTION for {}'.format(contact)
    message.contact.is_validated = True
    message.contact.save()
    return False # Don't continue validation check  s

###############
{'fraction_non_alphanumeric': 0.17080557238037553, 'fraction_numerical': 0.0012113870381586917, 'mean_word_length': 3.8645066273932254, 'pattern_counts': {'":': 0, '<': 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': '5183764', 'n_tokens_mistral': 889, 'n_tokens_neox': 888, 'n_words': 192}