# Path: phial/wrappers.py
# class Command:
#     """
#     An action executable from Slack.
# 
#     :param pattern: A string that a Slack Message must match to trigger
#                     execution
#     :param func: The function that will be triggered when the command is
#                   invoked
#     :param case_sensitive: Whether the :code:`pattern` should enforce case
#                            sensitivity
#     :param help_text_override: Overrides the function's docstring in the
#                                standard help command
#     :param hide_from_help_command: Prevents function from being displayed by
#                                    the standard help command
#     """
# 
#     def __init__(
#         self,
#         pattern: str,
#         func: Callable[..., PhialResponse],
#         case_sensitive: bool = False,
#         help_text_override: Optional[str] = None,
#         hide_from_help_command: Optional[bool] = False,
#     ):
#         self.pattern_string = pattern
#         self.pattern = self._build_pattern_regex(pattern, case_sensitive)
#         self.alias_patterns = self._get_alias_patterns(func)
#         self.func = func
#         self.case_sensitive = case_sensitive
#         self.help_text_override = help_text_override
#         self.hide_from_help_command = hide_from_help_command
# 
#     def __repr__(self) -> str:
#         return "<Command: {0}>".format(self.pattern_string)
# 
#     def _get_alias_patterns(self, func: Callable) -> List[Pattern]:
#         patterns: List[Pattern] = []
#         if hasattr(func, "alias_patterns"):
#             for pattern in func.alias_patterns:  # type: ignore
#                 patterns.append(self._build_pattern_regex(pattern))
#         return patterns
# 
#     @staticmethod
#     def _build_pattern_regex(
#         pattern: str, case_sensitive: bool = False
#     ) -> Pattern[str]:
#         command = re.sub(r"(<\w+>)", r"(\"?\1\"?)", pattern)
#         command_regex = re.sub(r"(<\w+>)", r'(?P\1[^"]*)', command)
#         return re.compile(
#             "^{}$".format(command_regex), 0 if case_sensitive else re.IGNORECASE
#         )
# 
#     def pattern_matches(self, message: Message) -> Optional[Dict[str, str]]:
#         """
#         Check if message should invoke the command.
# 
#         Checks whether the text of a :obj:`Message` matches the command's
#         pattern, or any of it's aliased patterns.
#         """
#         match = self.pattern.match(message.text)
#         if match:
#             return match.groupdict()
# 
#         # Only check aliases if main pattern does not match
#         for alias in self.alias_patterns:
#             match = alias.match(message.text)
#             if match:
#                 return match.groupdict()
# 
#         return None
# 
#     @property
#     def help_text(self) -> Optional[str]:
#         """A description of the command's function."""
#         if self.help_text_override is not None:
#             return self.help_text_override
#         return self.func.__doc__
# 
# class Message:
#     """
#     A representation of a Slack message.
# 
#     :param text: The message contents
#     :param channel: The Slack channel ID the message was sent from
#     :param user: The user who sent the message
#     :param timestamp: The message's timestamp
#     :param team: The Team ID of the Slack workspace the message was
#                  sent from
#     :param bot_id: If the message was sent by a bot
#                    the ID of that bot. Defaults to None.
#     """
# 
#     def __init__(
#         self,
#         text: str,
#         channel: str,
#         user: str,
#         timestamp: str,
#         team: Optional[str],
#         bot_id: Optional[str] = None,
#     ) -> None:
#         self.text = text
#         self.channel = channel
#         self.user = user
#         self.timestamp = timestamp
#         self.team = team
#         self.bot_id = bot_id
# 
#     def __repr__(self) -> str:
#         return "<Message: {0} in {1}:{2} at {3}>".format(
#             self.text, self.channel, self.team, self.timestamp
#         )
# 
#     def __eq__(self, other: object) -> bool:
#         return self.__dict__ == other.__dict__


from phial.wrappers import Command, Message

    command = Command("test", test, False, None)
    assert repr(command) == "<Command: test>"


def test_command_help_text() -> None:
    """Assert help text found from docstring."""

    def test() -> None:
        """Help text."""
        pass

    command = Command("test", test, False, None)
    assert command.help_text == "Help text."


def test_command_help_text_override() -> None:
    """Assert help text override works."""

    def test() -> None:
        """Help text."""
        pass

    command = Command("test", test, False, "Help text override")
    assert command.help_text == "Help text override"


def test_command_build_patter_regex_no_substition_ignore_case() -> None:
    """Assert case insensitive regex works correctly."""
    command_template = "test"

# Path: phial/wrappers.py
# class Command:
#     """
#     An action executable from Slack.
# 
#     :param pattern: A string that a Slack Message must match to trigger
#                     execution
#     :param func: The function that will be triggered when the command is
#                   invoked
#     :param case_sensitive: Whether the :code:`pattern` should enforce case
#                            sensitivity
#     :param help_text_override: Overrides the function's docstring in the
#                                standard help command
#     :param hide_from_help_command: Prevents function from being displayed by
#                                    the standard help command
#     """
# 
#     def __init__(
#         self,
#         pattern: str,
#         func: Callable[..., PhialResponse],
#         case_sensitive: bool = False,
#         help_text_override: Optional[str] = None,
#         hide_from_help_command: Optional[bool] = False,
#     ):
#         self.pattern_string = pattern
#         self.pattern = self._build_pattern_regex(pattern, case_sensitive)
#         self.alias_patterns = self._get_alias_patterns(func)
#         self.func = func
#         self.case_sensitive = case_sensitive
#         self.help_text_override = help_text_override
#         self.hide_from_help_command = hide_from_help_command
# 
#     def __repr__(self) -> str:
#         return "<Command: {0}>".format(self.pattern_string)
# 
#     def _get_alias_patterns(self, func: Callable) -> List[Pattern]:
#         patterns: List[Pattern] = []
#         if hasattr(func, "alias_patterns"):
#             for pattern in func.alias_patterns:  # type: ignore
#                 patterns.append(self._build_pattern_regex(pattern))
#         return patterns
# 
#     @staticmethod
#     def _build_pattern_regex(
#         pattern: str, case_sensitive: bool = False
#     ) -> Pattern[str]:
#         command = re.sub(r"(<\w+>)", r"(\"?\1\"?)", pattern)
#         command_regex = re.sub(r"(<\w+>)", r'(?P\1[^"]*)', command)
#         return re.compile(
#             "^{}$".format(command_regex), 0 if case_sensitive else re.IGNORECASE
#         )
# 
#     def pattern_matches(self, message: Message) -> Optional[Dict[str, str]]:
#         """
#         Check if message should invoke the command.
# 
#         Checks whether the text of a :obj:`Message` matches the command's
#         pattern, or any of it's aliased patterns.
#         """
#         match = self.pattern.match(message.text)
#         if match:
#             return match.groupdict()
# 
#         # Only check aliases if main pattern does not match
#         for alias in self.alias_patterns:
#             match = alias.match(message.text)
#             if match:
#                 return match.groupdict()
# 
#         return None
# 
#     @property
#     def help_text(self) -> Optional[str]:
#         """A description of the command's function."""
#         if self.help_text_override is not None:
#             return self.help_text_override
#         return self.func.__doc__
# 
# class Message:
#     """
#     A representation of a Slack message.
# 
#     :param text: The message contents
#     :param channel: The Slack channel ID the message was sent from
#     :param user: The user who sent the message
#     :param timestamp: The message's timestamp
#     :param team: The Team ID of the Slack workspace the message was
#                  sent from
#     :param bot_id: If the message was sent by a bot
#                    the ID of that bot. Defaults to None.
#     """
# 
#     def __init__(
#         self,
#         text: str,
#         channel: str,
#         user: str,
#         timestamp: str,
#         team: Optional[str],
#         bot_id: Optional[str] = None,
#     ) -> None:
#         self.text = text
#         self.channel = channel
#         self.user = user
#         self.timestamp = timestamp
#         self.team = team
#         self.bot_id = bot_id
# 
#     def __repr__(self) -> str:
#         return "<Message: {0} in {1}:{2} at {3}>".format(
#             self.text, self.channel, self.team, self.timestamp
#         )
# 
#     def __eq__(self, other: object) -> bool:
#         return self.__dict__ == other.__dict__


# Path: tests/wrappers/test_command.py
from phial.wrappers import Command, Message


    command = Command("test", test, False, None)
    assert repr(command) == "<Command: test>"


def test_command_help_text() -> None:
    """Assert help text found from docstring."""

    def test() -> None:
        """Help text."""
        pass

    command = Command("test", test, False, None)
    assert command.help_text == "Help text."


def test_command_help_text_override() -> None:
    """Assert help text override works."""

    def test() -> None:
        """Help text."""
        pass

    command = Command("test", test, False, "Help text override")
    assert command.help_text == "Help text override"


def test_command_build_patter_regex_no_substition_ignore_case() -> None:
    """Assert case insensitive regex works correctly."""
    command_template = "test"

    command_pattern = Command._build_pattern_regex(command_template, False)