All Projects → djangobot → djangobot

djangobot / djangobot

Licence: MIT license
Bridge between Slack and Django, via Channels

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to djangobot

slackbridge
Bridge between IRC and Slack running on Kubernetes
Stars: ✭ 12 (-81.82%)
Mutual labels:  twisted
ROSE
ROSE project car race game
Stars: ✭ 24 (-63.64%)
Mutual labels:  twisted
github-issues-notice
Notify labeled issues to Slack
Stars: ✭ 20 (-69.7%)
Mutual labels:  slack
transceiver
Channel based event bus with request/reply pattern, using promises. For node & browser.
Stars: ✭ 25 (-62.12%)
Mutual labels:  channels
SnitchDNS
Database Driven DNS Server with a Web UI
Stars: ✭ 169 (+156.06%)
Mutual labels:  twisted
go-observer
Go package for simplifying channel-based broadcasting of events from multiple publishers to multiple observers
Stars: ✭ 66 (+0%)
Mutual labels:  channels
Cardinal
A Python IRC bot, designed to make adding functionality quick and simple.
Stars: ✭ 92 (+39.39%)
Mutual labels:  twisted
slack-ascii
ASCII Emoticons for Slack!
Stars: ✭ 15 (-77.27%)
Mutual labels:  slack
channels
go channel patterns
Stars: ✭ 86 (+30.3%)
Mutual labels:  channels
ncolony
A colony of interacting processes
Stars: ✭ 23 (-65.15%)
Mutual labels:  twisted
File-Maker
Generate data files for Wii Channels that have the latest news, forecast data, etc.
Stars: ✭ 65 (-1.52%)
Mutual labels:  channels
24-game
24 point game implemented in Python, just for fun!
Stars: ✭ 16 (-75.76%)
Mutual labels:  twisted
swift-futures
Demand-driven asynchronous programming in Swift
Stars: ✭ 32 (-51.52%)
Mutual labels:  channels
xlbaidumap flutter
flutter 集成百度地图
Stars: ✭ 27 (-59.09%)
Mutual labels:  channels
captcha-generator
An NPM package to generate captcha images that can be used in Discord bots or various other projects
Stars: ✭ 45 (-31.82%)
Mutual labels:  slack
livelog
A Django Channels example project to demonstrate the ASGI use case.
Stars: ✭ 20 (-69.7%)
Mutual labels:  channels
Protobuf-Dreamer
A tiled DeepDream project for creating any size of image, on both CPU and GPU
Stars: ✭ 39 (-40.91%)
Mutual labels:  channels
django-channels-with-socket.io
django channels with socket.io
Stars: ✭ 23 (-65.15%)
Mutual labels:  channels
slack neuralyzer
Ruby gem for clean up messages and files on Slack.
Stars: ✭ 58 (-12.12%)
Mutual labels:  slack
YouTube to m3u
Grabs m3u from YouTube live.
Stars: ✭ 95 (+43.94%)
Mutual labels:  channels

Djangobot

Djangobot is a bridge between Slack and a Channels-enabled Django app.

Specifically, it is a protocol server that produces and consumes messages for channels-based apps.

It is built atop autobahn and twisted.

Installation & Usage

To install, simply use pip.

$ pip install djangobot

Djangobot should be installed in the virtual environment of your application as it needs to be able to import one of the specified channel layers defined in your settings.py.

Then, assuming your django project is named myapp, the ASGI file is named asgi.py and you've created a channel layer in it named channel_layer, run this command:

$ DJANGOBOT_TOKEN=[your slack token] djangobot myapp.asgi:channel_layer

In production, you'll want to keep this process alive with supervisor, circus or a similar tool.

What's it doing?

When beginning djangobot, it will:

  1. Connect to the Slack API and request users and channels for your team.
  2. Initiate a Real-Time Messaging Connection.
  3. Forward any RTM events onto the slack.{type} channel. For example, message events (whose type is message) are sent along the slack.message channel.
  4. Send any messages on the slack.send channel back to slack.

Receiving events in your application

In your routing.py, you'll need to specify consumer functions to handle events on the slack channels like so:

channel_routing = {
    'websocket.receive': 'path.to.my.consumer',
    'websocket.connect': 'path.to.another.consumer',
    'websocket.disconnect': 'path.to.yet.another.consumer',

    # Slack channels
    'slack.message': 'function.to.handle.slack.messages',
    'slack.hello': 'handle.when.djangobot.connects',
    # and so forth

Sending messages to slack

To send messages to slack, simply send a dictionary at least a text key. You may optionally include the channel on which to post the message. This can be the human-readable version or a channel id. Note that djangobot necessarily posts messages as the user tied to your Slack API token.

For example:

import channels

channels.Channel('slack.send').send({'text': 'Why hello there!', 'channel': 'general'})

Of course, part of the beauty of channels is that this can be done from anywhere.

Why is this useful?

This simply bridges your slack team to your production application in real-time. On it's own, it does nothing else. Implementing actual features is up to you. Off the top of my head, some ideas:

  1. Make Slack a logging destination.
  2. 2FA to approve certain tasks.
  3. Chat through Slack to users.

Contributing

  1. Fork this repository.
  2. Create a branch with your feature or bug fix.
  3. Work on it, push commits.
  4. Submit a Pull Request.

Todo

  1. Testing: I would appreciate help testing twisted clients.
  2. Setting up the reply channel: Right now both djangobot and applications must hard-code the slack.send outgoing channel name which isn't ideal.
  3. Logging: Djangobot could logger.debug a lot more.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].