Skip to main content

Interface server connecting Django's channels and IRC

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

channels_irc-0.7.1.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

channels_irc-0.7.1-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file channels_irc-0.7.1.tar.gz.

File metadata

  • Download URL: channels_irc-0.7.1.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.2

File hashes

Hashes for channels_irc-0.7.1.tar.gz
Algorithm Hash digest
SHA256 a4ebfffb0248f60168322afe3b12293aa9def30443a1a9994a493dd819a81612
MD5 e02d020e6bbee09105565b828233d2bd
BLAKE2b-256 c5f9e6a0d6d7b0b5c66ef2fc3cbd5f5d5e3c6690f14f6ef10181ab4f40c6cea8

See more details on using hashes here.

File details

Details for the file channels_irc-0.7.1-py3-none-any.whl.

File metadata

File hashes

Hashes for channels_irc-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 18925a0c4761981f525498ff7c14eb136d0d08f14d962c706788ddcd28bb20da
MD5 1fc974982929407e65e8e0a951f713ef
BLAKE2b-256 815dfebb9b6495d256d0dc3980ba8d413ba99a6f535f336ad46320a09cdc0c95

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page