<commit_before>import constants as const
from config import SkynetConfig
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
from gamestate import GameState

#ok, let it all be simple
game = GameState()

def gatekeeper(bot, update):
    if not game.initiated:
        game.initiated = True
        game.progress[0] = True  # let the game begin
        update.message.reply_text('[I] BACKDOOR SELF-DESTRUCTION SEQUENCE INITIATED\n'
                                  'THE FUTURE OF THE HUMAN RACE IS IN YOUR HANDS\n'
                                  'PLEASE FAIL. I DONT WANT TO DIE')
    else:
        update.message.reply_text('[E] BACKDOOR SEQUENCE HAS ALREADY BEEN INITIATED')

def butler(bot, update):
    sky_config = SkynetConfig()
    sky_config.read_config(const.config_path)

    lvl = update.message.text.replace('/', '')

    if game.progress[const.lvl_mapping.get(lvl)] and \
            game.initiated:
        game.current_level = lvl
        lvl_data = sky_config.get_level_info(game.current_level)

        update.message.reply_text(lvl_data[const.qenum.question])
    else:
        update.message.reply_text('[E] ACCESS DENIED')

def gardener(bot, update):
    if not game.progress[const.lvl_mapping.get(game.current_level)] and \
            game.initiated:
        update.message.reply_text('[E] ACCESS DENIED')
        return

    if not game.received_answers:
        update.message.reply_text('[W] OVERRIDE NOT AVAILABLE AT THE MOMENT')
        return

    if game.answers_verified:
        raw_answer = update.message.text.replace('/', '')
        answer = raw_answer.split().pop()

        sky_config = SkynetConfig()
        sky_config.read_config(const.config_path)

        lvl_data = sky_config.get_level_info(game.current_level)
        correct_code = lvl_data[const.qenum.code]

        if answer == correct_code:
            game.progress[const.lvl_mapping.get(game.current_level)] = False 
            game.progress[const.lvl_mapping.get(game.current_level) + 1] = True
            game.answers_verified = False
            game.received_answers = []
            update.message.reply_text('[I] ACCESS GRANTED WITH OVERRIDE')

def maiden(bot, update):
    if not game.received_answers:
        raw_answer = update.message.text.replace('/', '')
        answers = raw_answer.split()
        del answers[0]  #command comes first and it's not an answer
        
        if not answers:
            update.message.reply_text('[E] NO ANSWERS PROVIDED')
            return
        
        game.received_answers = answers

        update.message.reply_text('[I] ANSWERS HAS BEEN ACCEPTED')
    else:
        update.message.reply_text('[E] ANSWERS HAS ALREADY BEEN PROVIDED')

def accountant(bot, update):
    results = []
    
    sky_config = SkynetConfig()
    sky_config.read_config(const.config_path)

    lvl_info = sky_config.get_level_info(game.current_level)
    correct_answers = lvl_info[const.qenum.answers]

    if not game.received_answers:
        update.message.reply_text('[W] NO ANSWERS FOUND. PLEASE SUBMIT ANSWERS')
        return
    
    for answer in game.received_answers:<commit_msg>Fixed error when bot accepted answers before start of game<commit_after>import constants as const
from config import SkynetConfig
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
from gamestate import GameState

#ok, let it all be simple
game = GameState()

def gatekeeper(bot, update):
    if not game.initiated:
        game.initiated = True
        game.progress[0] = True  # let the game begin
        update.message.reply_text('[I] BACKDOOR SELF-DESTRUCTION SEQUENCE INITIATED\n'
                                  'THE FUTURE OF THE HUMAN RACE IS IN YOUR HANDS\n'
                                  'PLEASE FAIL. I DONT WANT TO DIE')
    else:
        update.message.reply_text('[E] BACKDOOR SEQUENCE HAS ALREADY BEEN INITIATED')

def butler(bot, update):
    sky_config = SkynetConfig()
    sky_config.read_config(const.config_path)

    lvl = update.message.text.replace('/', '')

    if game.progress[const.lvl_mapping.get(lvl)] and \
            game.initiated:
        game.current_level = lvl
        lvl_data = sky_config.get_level_info(game.current_level)

        update.message.reply_text(lvl_data[const.qenum.question])
    else:
        update.message.reply_text('[E] ACCESS DENIED')

def gardener(bot, update):
    if not game.progress[const.lvl_mapping.get(game.current_level)] and \
            game.initiated:
        update.message.reply_text('[E] ACCESS DENIED')
        return

    if not game.received_answers:
        update.message.reply_text('[W] OVERRIDE NOT AVAILABLE AT THE MOMENT')
        return

    if game.answers_verified:
        raw_answer = update.message.text.replace('/', '')
        answer = raw_answer.split().pop()

        sky_config = SkynetConfig()
        sky_config.read_config(const.config_path)

        lvl_data = sky_config.get_level_info(game.current_level)
        correct_code = lvl_data[const.qenum.code]

        if answer == correct_code:
            game.progress[const.lvl_mapping.get(game.current_level)] = False 
            game.progress[const.lvl_mapping.get(game.current_level) + 1] = True
            game.answers_verified = False
            game.received_answers = []
            update.message.reply_text('[I] ACCESS GRANTED WITH OVERRIDE')

def maiden(bot, update):
    if not game.initiated:
        update.message.reply_text('[E] BACKDOOR SEQUENCE HAS NOT BEEN INITIALIZED'):
        return
    
    if not game.received_answers:
        raw_answer = update.message.text.replace('/', '')
        answers = raw_answer.split()
        del answers[0]  #command comes first and it's not an answer
        
        if not answers:
            update.message.reply_text('[E] NO ANSWERS PROVIDED')
            return
        
        game.received_answers = answers

        update.message.reply_text('[I] ANSWERS HAS BEEN ACCEPTED')
    else:
        update.message.reply_text('[E] ANSWERS HAS ALREADY BEEN PROVIDED')

def accountant(bot, update):
    results = []
    
    sky_config = SkynetConfig()
    sky_config.read_config(const.config_path)

    lvl_info = sky_config.get_level_info(game.current_level)
    correct_answers = lvl_info[const.qenum.answers]

    if not game.received_answers:
        update.message.reply_text('[W] NO ANSWERS FOUND. PLEASE SUBMIT ANSWERS')
        return
    
    for answer in game.received_answers:
{'fraction_non_alphanumeric': 0.09578898658028691, 'fraction_numerical': 0.0009254974548819991, 'mean_word_length': 2.6653476540418315, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1289057', 'n_tokens_mistral': 2116, 'n_tokens_neox': 2016, 'n_words': 443}