<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def notify(self, subsystem, recipient, subject, body_html, body_text):
 """You can send messages either to channels and private groups by using the following formats #channel-name @username-direct-message Args: subsystem (`str`):
 Name of the subsystem originating the notification recipient (`str`):
 Recipient subject (`str`):
 Subject / title of the notification, not used for this notifier body_html (`str)`: HTML formatted version of the message, not used for this notifier body_text (`str`):
 Text formatted version of the message Returns: `None` """

        if not re.match(self.validation, recipient, re.I):
            raise ValueError('Invalid recipient provided')

        if recipient.startswith('#'):
            target_type = 'channel'

        elif recipient.find('@') != -1:
            target_type = 'user'

        else:
            self.log.error('Unknown contact type for Slack: {}'.format(recipient))
            return

        try:
            self._send_message(
                target_type=target_type,
                target=recipient,
                message=body_text,
                title=subject
            )
        except SlackError as ex:
            self.log.error('Failed sending message to {}: {}'.format(recipient, ex))