Interface server connecting Django's channels and IRC
Project description
# Channels-IRC
[![Join the chat at https://gitter.im/django-channels-irc/Lobby](https://badges.gitter.im/django-channels-irc/Lobby.svg)](https://gitter.im/django-channels-irc/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
A bridge between IRC and Django's `channels`. Built according to the [ASGI IRC spec](https://github.com/django/channels/blob/master/docs/asgi/irc-client.rst)
## Installation
run `python setup.py install` to install the library and set up the command line interface
## Usage
The interface server can be started by simply running the command,
```
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 filed 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`.
## IRC Consumers
`channels_irc` is comes with the `IrcConsumer` and the `AsyncIrcConsumer` for bootstrapping IRC connection handling.
```
from channels_irc import IrcConsumer
class MyConsumer(IrcConsumer):
def connect(self, server, port, nickname):
"""
Optional hook for actions on connection to IRC Server
"""
print('Connected to server {}:{} with nickname'.format(server, port, nickname)
def disconnect(self, server, port):
"""
Optionl hook fr actions on disconnect from IRC Server
"""
print('Disconnect from server {}:{}'.format(server, port)
def my_custom_action(self):
"""
Use built-in functions to send basic IRC commands
"""
self.message('my-channel', 'here is what I wanted to say')
```
Make sure to use `irc` as the protocol in the `ProtocolTypeRouter`
```
from channels.routing import ProtocolTypeRouter
from my_irc_app.consumers import MyConsumer
application = ProtocolTypeRouter({
'irc': MyConsumer,
})
```
[![Join the chat at https://gitter.im/django-channels-irc/Lobby](https://badges.gitter.im/django-channels-irc/Lobby.svg)](https://gitter.im/django-channels-irc/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
A bridge between IRC and Django's `channels`. Built according to the [ASGI IRC spec](https://github.com/django/channels/blob/master/docs/asgi/irc-client.rst)
## Installation
run `python setup.py install` to install the library and set up the command line interface
## Usage
The interface server can be started by simply running the command,
```
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 filed 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`.
## IRC Consumers
`channels_irc` is comes with the `IrcConsumer` and the `AsyncIrcConsumer` for bootstrapping IRC connection handling.
```
from channels_irc import IrcConsumer
class MyConsumer(IrcConsumer):
def connect(self, server, port, nickname):
"""
Optional hook for actions on connection to IRC Server
"""
print('Connected to server {}:{} with nickname'.format(server, port, nickname)
def disconnect(self, server, port):
"""
Optionl hook fr actions on disconnect from IRC Server
"""
print('Disconnect from server {}:{}'.format(server, port)
def my_custom_action(self):
"""
Use built-in functions to send basic IRC commands
"""
self.message('my-channel', 'here is what I wanted to say')
```
Make sure to use `irc` as the protocol in the `ProtocolTypeRouter`
```
from channels.routing import ProtocolTypeRouter
from my_irc_app.consumers import MyConsumer
application = ProtocolTypeRouter({
'irc': MyConsumer,
})
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
channels_irc-0.3-py3-none-any.whl
(10.4 kB
view hashes)
Close
Hashes for channels_irc-0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc27a70062361dbe15f727497ff2c64bf6c94600ab8d3305d31d0c20bd2aae1d |
|
MD5 | 030899edebbaefa9e701b5aafa6d3e16 |
|
BLAKE2b-256 | b47cfe3108c616db05cce178e17d841414c61a7cd8f29231f85a4273b391192e |