# Path: hypebot/hype_types.py

# 
# Path: hypebot/core/params_lib.py
# def _ParseChannel(channel):
# def _ParseChannels(channels):
#   def __init__(self, defaults=None):
#   def __str__(self):
#   def Override(self, params):
#   def _AssignValueConvertDict(self, key, value):
#   def _ParseDict(self, params):
#   def __setattr__(self, key, value):
#   def get(self, key, default_value=None):  # pylint: disable=invalid-name
#   def AsDict(self):
#   def Lock(self):
#   def _RaiseIfLocked(self):
# def MergeParams(defaults, *overrides):
# class HypeParams(object):
#   SPECIAL_ATTRS = ['_locked']
#   HAS_DYNAMIC_ATTRIBUTES = True
# 
# Path: hypebot/interfaces/interface_lib.py
# class BaseChatInterface(with_metaclass(abc.ABCMeta)):
#   DEFAULT_PARAMS = params_lib.HypeParams({
#       # Display name used when chatting.
#       'name': 'chatbot',
#   })
#   def __init__(self, params):
#   def RegisterHandlers(self, on_message_fn, user_tracker, user_prefs):
#   def Join(self, channel: hype_types.Channel):
#   def Leave(self, channel: hype_types.Channel):
#   def Loop(self):
#   def FindUser(self, query: Text) -> Optional[user_pb2.User]:
#   def WhoAll(self):
#   def SendMessage(self, channel: hype_types.Channel,
#                   message: Optional[hype_types.Message]):
#   def SendDirectMessage(self, user: user_pb2.User, message: hype_types.Message):
#   def Notice(self, channel: hype_types.Channel, message: hype_types.Message):
#   def Topic(self, channel: hype_types.Channel, new_topic: Text):


import re
import asyncio
import discord
from absl import logging
from typing import Optional, Text
from hypebot import hype_types
from hypebot.core import params_lib
from hypebot.interfaces import interface_lib
from hypebot.protos import channel_pb2
from hypebot.protos import user_pb2
    async def on_ready():
      self.WhoAll()

    @self._client.event
    async def on_member_join(member):
      if member.bot:
        self._user_tracker.AddBot(member.name)
      else:
        self._user_tracker.AddHuman(member.name)

  def _CleanContent(self, message):
    """Transforms user/channel mentions into their names."""
    transformations = {
        re.escape('<#{0.id}>'.format(channel)): '#' + channel.name
        for channel in message.channel_mentions
    }
    transformations.update({
        re.escape('<@{0.id}>'.format(member)): member.id
        for member in message.mentions
    })

    def repl(obj):
      return transformations.get(re.escape(obj.group(0)), '')

    pattern = re.compile('|'.join(transformations.keys()))
    return pattern.sub(repl, message.content)

  def Loop(self):
    self._client.run(self._params.token)


# Path: hypebot/hype_types.py

# 
# Path: hypebot/core/params_lib.py
# def _ParseChannel(channel):
# def _ParseChannels(channels):
#   def __init__(self, defaults=None):
#   def __str__(self):
#   def Override(self, params):
#   def _AssignValueConvertDict(self, key, value):
#   def _ParseDict(self, params):
#   def __setattr__(self, key, value):
#   def get(self, key, default_value=None):  # pylint: disable=invalid-name
#   def AsDict(self):
#   def Lock(self):
#   def _RaiseIfLocked(self):
# def MergeParams(defaults, *overrides):
# class HypeParams(object):
#   SPECIAL_ATTRS = ['_locked']
#   HAS_DYNAMIC_ATTRIBUTES = True
# 
# Path: hypebot/interfaces/interface_lib.py
# class BaseChatInterface(with_metaclass(abc.ABCMeta)):
#   DEFAULT_PARAMS = params_lib.HypeParams({
#       # Display name used when chatting.
#       'name': 'chatbot',
#   })
#   def __init__(self, params):
#   def RegisterHandlers(self, on_message_fn, user_tracker, user_prefs):
#   def Join(self, channel: hype_types.Channel):
#   def Leave(self, channel: hype_types.Channel):
#   def Loop(self):
#   def FindUser(self, query: Text) -> Optional[user_pb2.User]:
#   def WhoAll(self):
#   def SendMessage(self, channel: hype_types.Channel,
#                   message: Optional[hype_types.Message]):
#   def SendDirectMessage(self, user: user_pb2.User, message: hype_types.Message):
#   def Notice(self, channel: hype_types.Channel, message: hype_types.Message):
#   def Topic(self, channel: hype_types.Channel, new_topic: Text):


# Path: hypebot/interfaces/discord_interface.py
import re
import asyncio
import discord
from absl import logging
from typing import Optional, Text
from hypebot import hype_types
from hypebot.core import params_lib
from hypebot.interfaces import interface_lib
from hypebot.protos import channel_pb2
from hypebot.protos import user_pb2

    async def on_ready():
      self.WhoAll()

    @self._client.event
    async def on_member_join(member):
      if member.bot:
        self._user_tracker.AddBot(member.name)
      else:
        self._user_tracker.AddHuman(member.name)

  def _CleanContent(self, message):
    """Transforms user/channel mentions into their names."""
    transformations = {
        re.escape('<#{0.id}>'.format(channel)): '#' + channel.name
        for channel in message.channel_mentions
    }
    transformations.update({
        re.escape('<@{0.id}>'.format(member)): member.id
        for member in message.mentions
    })

    def repl(obj):
      return transformations.get(re.escape(obj.group(0)), '')

    pattern = re.compile('|'.join(transformations.keys()))
    return pattern.sub(repl, message.content)

  def Loop(self):
    self._client.run(self._params.token)


  def Who(self, user: hype_types.User):