<commit_before>from django.conf import settings

try:
    import slack
    import slack.chat

    slack.api_token = settings.SLACK_API_TOKEN

except ImportError:
    slack = None


def post_message(channel, message):
    """Post a message in a Slack Channel.

    e.g. to post in Tech:

        post_message("#tech", "hello world")

    """
    if slack:
        return slack.chat.post_message(
            channel,
            message,
            username=settings.SLACK_USERNAME
        )


def log_message(gcm_message, event, tfmt="%Y-%m-%d %H:%I:%S%z"):
    """Log some details about a GCM Message.  This is some
    temporary code to let me track the lifespace of messages
    for a specific user."""
<commit_msg>added a slack function that sends a private message<commit_after>from django.conf import settings

try:
    import slack
    import slack.chat
    import slack.users
    slack.api_token = settings.SLACK_API_TOKEN
except ImportError:
    slack = None


def post_private_message(slack_user, message):
    """Post a private message to a slack user (their slack username).

    Apears to arrive from Slackbot.

    """
    user_id = None
    if slack:

        users = slack.users.list()
        if users['ok']:
            for u in users['members']:
                if u['name'] == slack_user:
                    user_id = u['id']

    if user_id is not None:
        post_message(user_id, message)


def post_message(channel, message):
    """Post a message in a Slack Channel.

    e.g. to post in Tech:

        post_message("#tech", "hello world")

    """
    if slack:
        return slack.chat.post_message(
            channel,
            message,
            username=settings.SLACK_USERNAME
        )


def log_message(gcm_message, event, tfmt="%Y-%m-%d %H:%I:%S%z"):
    """Log some details about a GCM Message.  This is some
    temporary code to let me track the lifespace of messages
    for a specific user."""

{'fraction_non_alphanumeric': 0.09567901234567901, 'fraction_numerical': 0.0, 'mean_word_length': 2.4003496503496504, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6789656', 'n_tokens_mistral': 607, 'n_tokens_neox': 576, 'n_words': 191}