Skip to main content

A bridge between IRC and Django’s channels.

Installation

run pip install channels_irc to install the library and set up the command line interface

Documentation

Full docs available at django-channels-irc.readthedocs.io.

Requirements

Usage

Follow these steps to set up Django Channels IRC in your project

Add to INSTALLED_APPS

Add the library to INSTALLED_APPS:

INSTALLED_APPS = (
    ...
    'channels_irc',
)

Create a Consumer

Django Channels IRC contains two consumers for interacting with the IRC interface server: IrcConsumer and AsyncIrcConsumer:

from channels_irc import IrcConsumer

class MyIrcConsumer(IrcConsumer):
    def welcome(self, channel):
        """
        Optional hook for actions on connection to IRC Server
        """
        print('Connected to IRC with nickname'.format(nickname)

    def disconnect(self, server, port):
        """
        Optionl hook for actions on disconnect from IRC Server
        """
        print('Disconnect from server {}:{}'.format(server, port)

    def my_custom_message(self):
        """
        Use built-in functions to send basic IRC messages
        """
        self.send_message('my-channel', 'here is what I wanted to say')

    def my_custom_command(self):
        """
        You can also use built-in functions to send basic IRC commands
        """
        self.send_command('join', channel='some-other-channel')

Add your consumer(s) to your router

You can use the irc type in channels ProtocolTypeRouter to connect your new consumer to the interface server, and ensure your irc messages are delivered to the right place:

from channels.routing import ProtocolTypeRouter
from myapp.consumers import MyIrcConsumer

application = ProtocolTypeRouter({
    'irc': MyIrcConsumer.as_asgi(),
})

Start the interface server

The interface server can be started by simply running this in the command line:

channels-irc

The server requires that the server, nickname, and application properties be set. The application should be an import string pointing to the location of your app’s ASGI application. Hence, if your app was named myapp, contained an ASGI file called asgi.py, and your ASGI application is named my_application, you could start the server by running:

channels-irc -s 'irc.freenode.net' -n 'my_irc_nickname' -a 'myapp.asgi:my_application'

You can also set these values using the env variables CHANNELS_IRC_SERVER, CHANNELS_IRC_NICKNAME, and CHANNELS_IRC_LAYER.

Release files for channels-irc 0.7.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for channels-irc 0.7.1
File Size Uploaded
channels_irc-0.7.1.tar.gz 13.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for channels-irc 0.7.1
File Interpreter ABI Platform
channels_irc-0.7.1-py3-none-any.whl Python 3 none any Details

Total release size: 29.6 kB

Release files / channels_irc-0.7.1.tar.gz

Download URL channels_irc-0.7.1.tar.gz
Size 13.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a4ebfffb0248f60168322afe3b12293aa9def30443a1a9994a493dd819a81612
BLAKE2b-256 checksum
How to use checksums
c5f9e6a0d6d7b0b5c66ef2fc3cbd5f5d5e3c6690f14f6ef10181ab4f40c6cea8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.2

Release files / channels_irc-0.7.1-py3-none-any.whl

Download URL channels_irc-0.7.1-py3-none-any.whl
Size 15.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
18925a0c4761981f525498ff7c14eb136d0d08f14d962c706788ddcd28bb20da
BLAKE2b-256 checksum
How to use checksums
815dfebb9b6495d256d0dc3980ba8d413ba99a6f535f336ad46320a09cdc0c95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.2

Release history Release notifications | RSS feed

This release

0.7.1 This release

2 release files

0.7.0

3 release files

0.6.2

2 release files

0.6.1

3 release files

0.6.0

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

3 release files

0.5.2

3 release files

0.5.1

2 release files

0.5.0

3 release files

0.4.1

2 release files

0.4.0

1 release file

0.3

1 release file

0.2

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page