text: from typing import Union, Match
  import re
  import random
  
  __author__ = "Benedict Thompson"
  __copyright__ = "Copyright 2019"
  __credits__ = ["Benedict Thompson"]
  __license__ = "MIT"
  __version__ = "0.0.1p"
  __maintainer__ = "Benedict Thompson"
  __email__ = "thomp334@uni.coventry.ac.uk"
  __status__ = "Pre-alpha"
  
  from chatter_box.users import UserBase
  
  _SELF_NAME = r"Chat-?bot"
  _PATTERN_NAME = re.compile(_SELF_NAME, re.IGNORECASE)
  
  _GREETINGS = [r"Hi", r"Hello", r"Hey"]
  _PATTERN_GREETING = re.compile(r'^(' + r'|'.join(_GREETINGS) + r'),? ?(' + _SELF_NAME + r')?', re.IGNORECASE)
  
  class Chatbot:
      """Platform independent chatbot implementation"""
  
      def __init__(self) -> None:
          pass  # TODO: initialise the chatbot.
  
      def parse(self, user: UserBase, user_input: str) -> Union[None, str]:
          """
          :param user: the user who sent the message
          :param user_input: the whole text entered by the user
          :return: str: the response to send back (or None if thi message ws unused)
          """
          match = _PATTERN_GREETING.search(user_input)
          if match:
              return self.process_greeting(match, user)
          return None
  
      def process_greeting(self, match: Match, user: UserBase) -> str:
          greeting = match.group(1)
          name = match.group(2)
  
          if name is not None:
              user_name = user.name
              return "{0}, {1}.".format(greeting, user_name)
          return "{0}!".format(random.choice(_GREETINGS))
  