<gh_stars>1-10
import json
import requests

from django.conf import settings

from utils.debug import Debug  # noqa


SLACK_URL_CHAT = 'https://slack.com/api/chat.postMessage'


class _SlackHelper(object):
    def get_headers(self):
        headers = {
            'Content-Type': 'application/json; charset=utf-8',
            'Authorization': 'Bearer ' + settings.SLACK_TOKEN
        }
        return headers

    def chat(self, message):
        data = {
            'link_names': True,
            'channel': settings.SLACK_CHANNEL,
            'text': message
        }

        response = requests.post(
            SLACK_URL_CHAT,
            headers=self.get_headers(),
            data=json.dumps(data)
        )

        text = json.loads(response.text)
        if not text.get('ok'):
            Debug.trace(text)

    def shout(self, message):
        self.chat('@here ' + message)


SlackHelper = _SlackHelper()

import json
import requests

from django.conf import settings

from utils.debug import Debug  # noqa


SLACK_URL_CHAT = 'https://slack.com/api/chat.postMessage'


class _SlackHelper(object):
    def get_headers(self):
        headers = {
            'Content-Type': 'application/json; charset=utf-8',
            'Authorization': 'Bearer ' + settings.SLACK_TOKEN
        }
        return headers

    def chat(self, message):
        data = {
            'link_names': True,
            'channel': settings.SLACK_CHANNEL,
            'text': message
        }

        response = requests.post(
            SLACK_URL_CHAT,
            headers=self.get_headers(),
            data=json.dumps(data)
        )

        text = json.loads(response.text)
        if not text.get('ok'):
            Debug.trace(text)

    def shout(self, message):
        self.chat('@here ' + message)


SlackHelper = _SlackHelper()