<commit_before>from slackclient import SlackClient  # type: ignore
import re
from typing import Dict, List, Pattern, Callable, Union, Tuple, Any, Optional
import logging
import json
from phial.commands import help_command
from phial.globals import _command_ctx_stack, command, _global_ctx_stack
from phial.wrappers import Command, Response, Message, Attachment
from phial.scheduler import Scheduler, Schedule, ScheduledJob


class Phial():
    '''
    The Phial object acts as the central object. It is given a token and an
    optional config dictionary. Once created it holds the core components of
    the bot, including command functions, command patterns and more.
    '''

    #: Default configuration
    default_config = {
        'prefix': "!",
        'registerHelpCommand': True,
        'baseHelpText': "All available commands:"
    }

    def __init__(self,
                 token: str,
                 config: dict = default_config,
                 logger: logging.Logger = logging.getLogger(__name__)) -> None:
        self.slack_client = SlackClient(token)
        self.commands = {}  # type: Dict[Pattern[str], Callable]
        self.command_names = {}  # type: Dict[Pattern[str], str]
        self.middleware_functions = []  # type: List[Callable]
        self.config = config
        self.running = False
        self.logger = logger
        self.scheduler = Scheduler()

        _global_ctx_stack.push({})
        self._register_standard_commands()

    def _register_standard_commands(self) -> None:
        '''
        Register any standard commands respecting the configuration provided
        '''
        if self.config['registerHelpCommand']:
            # The command function has to be a lambda as we wish to delay
            # execution until all commands have been registered.
            self.add_command("help", lambda: help_command(self),
                             help_text_override="List all available commmands")

    @staticmethod
    def _build_command_pattern(command: str,
                               case_sensitive: bool) -> Pattern[str]:
        '''Creates the command pattern regexs'''
        command_regex = re.sub(r'(<\w+>)', r'(?P\1.+)', command)
        return re.compile("^{}$".format(command_regex),
                          0 if case_sensitive else re.IGNORECASE)

    def add_command(self,
                    command_pattern_template: str,<commit_msg>Configure default logger to give output<commit_after>from slackclient import SlackClient  # type: ignore
import re
from typing import Dict, List, Pattern, Callable, Union, Tuple, Any, Optional
import logging
import json
from phial.commands import help_command
from phial.globals import _command_ctx_stack, command, _global_ctx_stack
from phial.wrappers import Command, Response, Message, Attachment
from phial.scheduler import Scheduler, Schedule, ScheduledJob


class Phial():
    '''
    The Phial object acts as the central object. It is given a token and an
    optional config dictionary. Once created it holds the core components of
    the bot, including command functions, command patterns and more.
    '''

    #: Default configuration
    default_config = {
        'prefix': "!",
        'registerHelpCommand': True,
        'baseHelpText': "All available commands:"
    }

    def __init__(self,
                 token: str,
                 config: dict = default_config,
                 logger: Optional[logging.Logger] = None) -> None:
        self.slack_client = SlackClient(token)
        self.commands = {}  # type: Dict[Pattern[str], Callable]
        self.command_names = {}  # type: Dict[Pattern[str], str]
        self.middleware_functions = []  # type: List[Callable]
        self.config = config
        self.running = False
        self.scheduler = Scheduler()
        if logger is None:
            logger = logging.getLogger(__name__)
            if not logger.hasHandlers():
                handler = logging.StreamHandler()
                formatter = logging.Formatter(fmt="%(asctime)s - %(message)s")
                handler.setFormatter(formatter)
                logger.addHandler(handler)
            logger.setLevel(logging.INFO)
        self.logger = logger

        _global_ctx_stack.push({})
        self._register_standard_commands()

    def _register_standard_commands(self) -> None:
        '''
        Register any standard commands respecting the configuration provided
        '''
        if self.config['registerHelpCommand']:
            # The command function has to be a lambda as we wish to delay
            # execution until all commands have been registered.
            self.add_command("help", lambda: help_command(self),
                             help_text_override="List all available commmands")

    @staticmethod
    def _build_command_pattern(command: str,
                               case_sensitive: bool) -> Pattern[str]:
        '''Creates the command pattern regexs'''
        command_regex = re.sub(r'(<\w+>)', r'(?P\1.+)', command)
        return re.compile("^{}$".format(command_regex),
                          0 if case_sensitive else re.IGNORECASE)

    def add_command(self,
                    command_pattern_template: str,
{'fraction_non_alphanumeric': 0.09042145593869731, 'fraction_numerical': 0.0007662835249042146, 'mean_word_length': 2.5016767270288396, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '7504627', 'n_tokens_mistral': 1364, 'n_tokens_neox': 1334, 'n_words': 409}