lamby / django-slack

Slack integration for Django, using the templating engine to generate messages
https://django-slack.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
241 stars 57 forks source link

Not able to override the slack channel #110

Closed VineetKumarKushwaha closed 3 years ago

VineetKumarKushwaha commented 3 years ago

Not able to find out any documentation which explains how can I override the slack-channel for each messages. I checked here https://django-slack.readthedocs.io/ and it says something like this You can override on a per-message level by specifying a {% block channel %}{% endblock %} in your message template. but I didn't get it how we can do it.

So I digged into the code and found that if we pass like this ideally it should work but I am getting 'not_in_channel' error

from django_slack import slack_message

slack_message(f'{BASE_DIR}/slack/{message_identifier}.slack', {
            'message': message, 
            'data': messageObject
 }, channel='#channel-name')

.slack file

{% extends django_slack %}

{% load django_slack %}
{% block text %}
Message: {{ message|escapeslack }}
Data: {{ data|escapeslack }}
{% endblock %}
lamby commented 3 years ago

not_in_channel

Not an expert on this, but are you sure your bot/user is in that channel? A quick Google suggests that you may need to /invite them in first. (As in, are we sure this is even something django-slack can 'fix' or workaround?)

VineetKumarKushwaha commented 3 years ago

Thanks it worked. Closing the issue indeed was not related to this package