def create(self, name_or_class, mask, filepath=None, **kwargs):
        """Create a new DCC connection. Return an ``asyncio.Protocol``"""
        if isclass(name_or_class):
            name = name_or_class.type
            protocol = name_or_class
        else:
            name = name_or_class
            protocol = self.protocols[name]
        assert name in DCC_TYPES
        if filepath:
            kwargs.setdefault('limit_rate',
                              self.config['send_limit_rate'])
            kwargs['filepath'] = filepath
            if protocol.type == DCCSend.type:
                kwargs.setdefault('offset', 0)
                kwargs.update(
                    filename_safe=slugify(os.path.basename(filepath)),
                    filesize=os.path.getsize(filepath),
                )
            elif protocol.type == DCCGet.type:
                try:
                    offset = os.path.getsize(filepath)
                except OSError:
                    offset = 0
                kwargs.setdefault('offset', offset)
                kwargs.setdefault('resume', False)
        kwargs.setdefault('port', None)
        f = protocol(
            mask=mask, ip=int(self.bot.ip),
            bot=self.bot, loop=self.loop, **kwargs)

        if kwargs['port']:
            task = asyncio.async(
                self.loop.create_connection(f.factory, f.host, f.port),
                loop=self.loop)
            task.add_done_callback(partial(self.created, f))
        else:
            task = asyncio.async(
                self.loop.create_server(
                    f.factory, '0.0.0.0', 0, backlog=1),
                loop=self.loop)
            task.add_done_callback(partial(self.created, f))
        return f
dataset/ETHPy150Open gawel/irc3/irc3/dcc/manager.py/DCCManager.create/original