-
-
Save astrotars/92559dda18f5808806fd054097d8d9b4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.management.base import BaseCommand, CommandError | |
from django.conf import settings | |
from stream_chat import StreamChat | |
class Command(BaseCommand): | |
help = 'Broadcast the message on your channel' | |
def add_arguments(self, parser): | |
parser.add_argument('--message') | |
def handle(self, *args, **options): | |
client = StreamChat(api_key=settings.STREAM_API_KEY, api_secret=settings.STREAM_API_SECRET) | |
client.update_user({"id": "system", "name": "The Server"}) | |
channel = client.channel("messaging", "kung-fu") | |
channel.create("system") | |
response = channel.send_message({"text": "AMA about kung-fu"}, 'system') | |
self.stdout.write(self.style.SUCCESS('Successfully posted a message with id "%s"' % response['message']['id'])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment