irc3.dcc DCC

See dcc_chat(), dcc_get() and dcc_send()

Here is a simple plugin to send a generated file:

# -*- coding: utf-8 -*-
import os
import string
import tempfile
import irc3
from irc3.plugins.command import command


@irc3.plugin
class DCC(object):

    filename = os.path.join(tempfile.gettempdir(), 'to_send')

    def __init__(self, bot):
        self.bot = bot
        if not os.path.isfile(self.filename):
            # create a file to send
            with open(self.filename, 'wb') as fd:
                for i in range(64 * 2048):
                    fd.write(string.ascii_letters.encode('utf8'))

    @command
    async def send(self, mask, target, args):
        """ DCC SEND command

            %%send
        """
        conn = await self.bot.dcc_send(mask, self.filename)
        self.bot.log.debug('%s ready', conn)

API

class irc3.dcc.DCCManager(bot)[source]

Manage DCC connections

create(name_or_class, mask, filepath=None, **kwargs)[source]

Create a new DCC connection. Return an asyncio.Protocol

is_allowed(name_or_class, mask)[source]

Return True is a new connection is allowed

resume(mask, filename, port, pos)[source]

Resume a DCC send

class irc3.dcc.DCCChat(**kwargs)[source]

DCC CHAT implementation

connection_made(transport)[source]

Called when a connection is made.

The argument is the transport representing the pipe connection. To receive data, wait for data_received() calls. When the connection is closed, connection_lost() is called.

data_received(data)[source]

data received

decode(data)[source]

Decode data with bot’s encoding

class irc3.dcc.DCCSend(**kwargs)[source]

DCC SEND implementation

connection_made(transport)[source]

Called when a connection is made.

The argument is the transport representing the pipe connection. To receive data, wait for data_received() calls. When the connection is closed, connection_lost() is called.

data_received(data)[source]

Called when some data is received.

The argument is a bytes object.

class irc3.dcc.DCCGet(**kwargs)[source]

DCC GET implementation

connection_made(transport)[source]

Called when a connection is made.

The argument is the transport representing the pipe connection. To receive data, wait for data_received() calls. When the connection is closed, connection_lost() is called.

data_received(data)[source]

Called when some data is received.

The argument is a bytes object.