This release is a pre-release and may not be stable for production use.
slack-channeler
Power a Slack bot with Django Channels v2
Installation
pip install slack-channeler
Usage
slack-channeler relies on the channel layer. First, ensure it's setup. channels-redis is recommended.
# settings.py
CHANNEL_LAYERS = {
'default': {
'BACKEND': 'channels_redis.core.RedisChannelLayer',
'CONFIG': {
"hosts": [('localhost', 6379)],
},
},
}
Create a consumer to handle Slack events
# consumers.py
from channels.consumer import AsyncConsumer, get_handler_name
class SlackConsumer(AsyncConsumer):
async def dispatch(self, message):
handler = getattr(self, get_handler_name(message), None)
if handler:
await handler(**message['data'])
async def slack_message(self, channel, text, **kwargs):
# Simply echo back message
await self.channel_layer.send('slack', {
'type': 'message',
'channel': channel,
'text': text,
})
Route Slack events to the consumer
# routing.py
from channels.routing import ProtocolTypeRouter, ChannelNameRouter
from .consumers import SlackConsumer
application = ProtocolTypeRouter({
'channel': ChannelNameRouter({
'slack': SlackConsumer,
}),
})
Start a Channels worker to handle Slack events from the channel layer
python manage.py runworker slack
Lastly, run slack-channeler
SLACK_CHANNELER_TOKEN=xoxb-12345678900-098765432100-DeadBeefFeed90iIJjYsf3ay slack_channeler
Building package
Currently, poetry does not support dynamic generation of version files, nor custom hooks to do so. To keep pyproject.toml the source of authority for version numbers, a custom build.py script is used to dynamically generate version.py.
To build slack-channeler, run python build.py. This has the same semantics as poetry build.
Metadata
Release files for slack-channeler 0.0.1.dev0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| slack-channeler-0.0.1.dev0.tar.gz | 4.8 kB | Without provenance | Details for slack-channeler-0.0.1.dev0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| slack_channeler-0.0.1.dev0-py3-none-any.whl | Python 3 | none | any | Details for slack_channeler-0.0.1.dev0-py3-none-any.whl |
Total release size: 10.5 kB
Release files / slack-channeler-0.0.1.dev0.tar.gz
| Download URL | slack-channeler-0.0.1.dev0.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dede07b867daa72ed555a802a4bcb83b05678702067749e733606e08272b2c85
|
|
BLAKE2b-256 checksum How to use checksums |
8779bdfd620b9eef340899975676cef82f76b47ed20998233654603a6ad22753
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.32.2 CPython/3.7.1
|
Release files / slack_channeler-0.0.1.dev0-py3-none-any.whl
| Download URL | slack_channeler-0.0.1.dev0-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1b28f859e591ada5db8b81903e3752c6d521f3fecb659401df47cbc68bf99bd8
|
|
BLAKE2b-256 checksum How to use checksums |
bc823fa40f341d05f6d2effc1a05d358e46ee9e746637f23c25893aff16aef79
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.32.2 CPython/3.7.1
|
Security for slack-channeler 0.0.1.dev0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.