<commit_before>import re

from config import ConfigManager
import command
import irc

class Action:
    actions = []

    def __init__(self, run_once=False, **kwargs):
        self.regex = kwargs['regex']
        self.action = kwargs['action']
        self.run_once = run_once

    def execute(self, action_mo):
        self.action(action_mo)

    def check_match_and_execute(self, message):
        action_mo = re.match(self.regex, message)
        if action_mo:
            self.action(action_mo)
            if self.run_once:
                Action.actions.remove(self)

class MessageInterpreter:
    action_insertion_queue = []

    @staticmethod
    def register_default_actions():
        def bot_command_action(bot_command_mo):
            command.execute(
                caller_nick=bot_command_mo.group(1),
                channel=bot_command_mo.group(2),
                command=bot_command_mo.group(3),
                arguments=bot_command_mo.group(4)
            )

        # Bot command action
        # :blaine!blaine@Clk-E28261F1 PRIVMSG #test :.tell
        actions = [Action(
            regex=r"^:([^\s]+)![^\s]+ PRIVMSG ([^\s]+) :%s([\w]+)[\s]*(.*)" % re.escape(ConfigManager.get('command_prefix')),
            action=bot_command_action
        ),

        # Pinging
        Action(
            regex=r"^PING .*",
            action=lambda match_object: irc.pong(match_object.group(0))
        ),

        # Connection accepted (AKA RPL_WELCOME, status 001)
        Action(
            regex=r".* 001 %s" % ConfigManager.get('nick'),
            action=lambda match_object: irc.join_config_channels()
        ),

        # Nickname registered already
        # ':NickServ!NickServ@snoonet/services/NickServ NOTICE nickenbot :This nickname is registered and protected.  If it is your'

        Action(
            regex=r"^:NickServ!NickServ@[^\s]+ NOTICE %s :.*registered.*" % ConfigManager.get('nick'),
            action=lambda match_object: irc.identify_with_nickserv()<commit_msg>Adds hyphens to bot-command matching<commit_after>import re

from config import ConfigManager
import command
import irc

class Action:
    actions = []

    def __init__(self, run_once=False, **kwargs):
        self.regex = kwargs['regex']
        self.action = kwargs['action']
        self.run_once = run_once

    def execute(self, action_mo):
        self.action(action_mo)

    def check_match_and_execute(self, message):
        action_mo = re.match(self.regex, message)
        if action_mo:
            self.action(action_mo)
            if self.run_once:
                Action.actions.remove(self)

class MessageInterpreter:
    action_insertion_queue = []

    @staticmethod
    def register_default_actions():
        def bot_command_action(bot_command_mo):
            command.execute(
                caller_nick=bot_command_mo.group(1),
                channel=bot_command_mo.group(2),
                command=bot_command_mo.group(3),
                arguments=bot_command_mo.group(4)
            )

        # Bot command action
        # :blaine!blaine@Clk-E28261F1 PRIVMSG #test :.tell
        actions = [Action(
            regex=r"^:([^\s]+)![^\s]+ PRIVMSG ([^\s]+) :%s([\w-]+)[\s]*(.*)" % re.escape(ConfigManager.get('command_prefix')),
            action=bot_command_action
        ),

        # Pinging
        Action(
            regex=r"^PING .*",
            action=lambda match_object: irc.pong(match_object.group(0))
        ),

        # Connection accepted (AKA RPL_WELCOME, status 001)
        Action(
            regex=r".* 001 %s" % ConfigManager.get('nick'),
            action=lambda match_object: irc.join_config_channels()
        ),

        # Nickname registered already
        # ':NickServ!NickServ@snoonet/services/NickServ NOTICE nickenbot :This nickname is registered and protected.  If it is your'

        Action(
            regex=r"^:NickServ!NickServ@[^\s]+ NOTICE %s :.*registered.*" % ConfigManager.get('nick'),
            action=lambda match_object: irc.identify_with_nickserv()
{'fraction_non_alphanumeric': 0.1199207135777998, 'fraction_numerical': 0.00842418235877106, 'mean_word_length': 2.3557772236076477, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5246184', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1221, 'n_words': 227}