class_docstr: Slack input channel implementation. Based on the HTTPInputChannel.
class_docstr_tok: ["Slack","input","channel","implementation",".","Based","on","the","HTTPInputChannel","."]
docstr: Remove superfluous/wrong/problematic tokens from a message.
  
  Probably a good starting point for pre-formatting of user-provided text
  to make NLU's life easier in case they go funky to the power of extreme
  
  In the current state will just drop self-mentions of bot itself
  
  Args:
      text: raw message as sent from slack
      uids_to_remove: a list of user ids to remove from the content
  
  Returns:
      str: parsed and cleaned version of the input text
docstr_tok: ["Remove","superfluous\/wrong\/problematic","tokens","from","a","message",".","Probably","a","good","starting","point","for","pre-formatting","of","user-provided","text","to","make","NLU","'s","life","easier","in","case","they","go","funky","to","the","power","of","extreme","In","the","current","state","will","just","drop","self-mentions","of","bot","itself","Args",":","text",":","raw","message","as","sent","from","slack","uids_to_remove",":","a","list","of","user","ids","to","remove","from","the","content","Returns",":","str",":","parsed","and","cleaned","version","of","the","input","text"]
code: def _sanitize_user_message(
      text: Text, uids_to_remove: Optional[List[Text]]
  ) -> Text:
      """Remove superfluous/wrong/problematic tokens from a message.
  
      Probably a good starting point for pre-formatting of user-provided text
      to make NLU's life easier in case they go funky to the power of extreme
  
      In the current state will just drop self-mentions of bot itself
  
      Args:
          text: raw message as sent from slack
          uids_to_remove: a list of user ids to remove from the content
  
      Returns:
          str: parsed and cleaned version of the input text
      """
      uids_to_remove = uids_to_remove or []
  
      for uid_to_remove in uids_to_remove:
          escaped_uid = re.escape(str(uid_to_remove))
  
          # heuristic to format majority cases OK
          # can be adjusted to taste later if needed,
          # but is a good first approximation
          for regex, replacement in [
              (rf"<@{escaped_uid}>\s", ""),
              (
                  rf"\s<@{escaped_uid}>",
                  "",
              ),  # a bit arbitrary but probably OK
              (rf"<@{escaped_uid}>", " "),
          ]:
              text = re.sub(regex, replacement, text)
  
      # Find multiple mailto or http links like
      # <mailto:xyz@rasa.com|xyz@rasa.com> or
      # <http://url.com|url.com> in text and substitute
      # it with original content
      pattern = r"(\<(?:mailto|https?):\/\/.*?\|.*?\>)"
      match = re.findall(pattern, text)
  
      if match:
          for remove in match:
              replacement = remove.split("|")[1]
              replacement = replacement.replace(">", "")
              text = text.replace(remove, replacement)
      return text.strip()
  
imports: import asyncio
  import hashlib
  import hmac
  from http import HTTPStatus
  import json
  import logging
  import re
  import time
  from typing import Any, Awaitable, Callable, Dict, List, Optional, Set, Text
  from rasa.core.channels.channel import InputChannel, OutputChannel, UserMessage
  from rasa.shared.constants import DOCS_URL_CONNECTORS_SLACK
  from rasa.shared.exceptions import InvalidConfigException
  import rasa.shared.utils.io
  from sanic import Blueprint, response
  from sanic.request import Request
  from sanic.response import HTTPResponse
  from slack_sdk.web.async_client import AsyncWebClient
label_desc: Use image node_id 8 for calling the SlackInput obj's underlying member method code with example usage: obj._sanitize_user_message(text, uids_to_remove) and returns: text