ChannelBox it is a simple tool for Starlette framework that allows you send messages to groups of channels.
Project description
ChannelBox
ChannelBox it is a simple tool for Starlette framework that allows you send messages to groups of channels.
Example of use:
- chats
- notifications from backend
- alerts
https://github.com/Sobolev5/channel-box
Install
To install run:
pip install channel-box
ChannelEndpoint methods
Change encoding and expires time on initial (default values is self.expires = 60 * 60 * 24, self.encoding = "json"):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.expires = 1600
self.encoding = "json"
Get or create group by name (only ASCII symbols allowed):
self.get_or_create('my_chat_1')
self.get_or_create('alert_channel_1')
Send message to group:
await self.group_send('my_chat_1', {"username": "New User", "message": "Hello world"})
await self.group_send('alert_channel_1', {"username": "New User", "message": "Hello world"})
channel_groups methods
Send message to any group from any part of your code:
await channel_groups.group_send('my_chat_1', {"username": "New User", "message": "Hello world"})
Show groups and channels:
channel_groups.groups_show()
Flush all groups and channels:
channel_groups.groups_flush()
Full working example
https://github.com/Sobolev5/channel-box/tree/master/example
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
Close
Hashes for channel_box-0.2.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67752ca706531162fc6d61a5b8eff1ef8c7c6f9b26ef9541155259ed9a55700a |
|
MD5 | d7a1fff4c42cffec2be8bb851fda32b8 |
|
BLAKE2b-256 | 64824be2c3af1bd12c062c66378a24c9e06feba1f81be26cc2abba826c678b26 |