<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from hashlib import md5
from os import environ

import bottle
from bottle import abort, request
from channels.backends.slack import SlackChannel
import requests


app = bottle.default_app()

app.config.load_config("app.conf")
config = {
    "yo_callback_url": app.config.get(
        "yo.callback_url", environ.get("YOTOSLACK_YO_CALLBACK_URL")),
    "slack_channel": app.config.get(
        "slack.channel", environ.get("YOTOSLACK_SLACK_CHANNEL")),
    "slack_url": app.config.get(
        "slack.webhook_url", environ.get("YOTOSLACK_SLACK_URL"))
}

colors = [
    "#1ABC9C",
    "#2ECC71",
    "#3498DB",
    "#34495E",
    "#16A085",
    "#F1C40F",
    "#2980B9",
    "#8E44AD"
]

photo_content_types = (
    "image/jpeg",
    "image/png",
)

@app.route(config["yo_callback_url"])
def index():
    # Parse query
    username = request.query.username
    link = request.query.link
    location = request.query.location

    # Query validation
    if username == "":
        return abort(400)

    # Message generation
    color = colors[int(md5(username.encode("utf-8")).hexdigest(), 16)
                   % len(colors)]
    attachments = [
        {
            "color": color,
            "fields": []
        }
    ]

    message = "Yo{type} from " + username

    if link != "":
        # Check whether link is photo or not
        if check_yo_photo(link):
            message = message.format(type=" Photo :camera:")
            attachments[0]["fields"].append({
                "title": "Link",
                "value": link,
                "short": False
            })
            attachments[0]["image_url"] = link
        else:
            message = message.format(type=" Link :link:")
            attachments[0]["fields"].append({
                "title": "Link",
                "value": link,
                "short": False
            })
    elif location != "":
        message = message.format(type=" Location")
        coordinate = location.replace(";", ",")

        # Reverse geocoding
        address = reverse_geocoding(coordinate)
        if address is not None:
            attachments[0]["fields"].append({<commit_msg>Add an emoji to Yo Location<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from hashlib import md5
from os import environ

import bottle
from bottle import abort, request
from channels.backends.slack import SlackChannel
import requests


app = bottle.default_app()

app.config.load_config("app.conf")
config = {
    "yo_callback_url": app.config.get(
        "yo.callback_url", environ.get("YOTOSLACK_YO_CALLBACK_URL")),
    "slack_channel": app.config.get(
        "slack.channel", environ.get("YOTOSLACK_SLACK_CHANNEL")),
    "slack_url": app.config.get(
        "slack.webhook_url", environ.get("YOTOSLACK_SLACK_URL"))
}

colors = [
    "#1ABC9C",
    "#2ECC71",
    "#3498DB",
    "#34495E",
    "#16A085",
    "#F1C40F",
    "#2980B9",
    "#8E44AD"
]

photo_content_types = (
    "image/jpeg",
    "image/png",
)

@app.route(config["yo_callback_url"])
def index():
    # Parse query
    username = request.query.username
    link = request.query.link
    location = request.query.location

    # Query validation
    if username == "":
        return abort(400)

    # Message generation
    color = colors[int(md5(username.encode("utf-8")).hexdigest(), 16)
                   % len(colors)]
    attachments = [
        {
            "color": color,
            "fields": []
        }
    ]

    message = "Yo{type} from " + username

    if link != "":
        # Check whether link is photo or not
        if check_yo_photo(link):
            message = message.format(type=" Photo :camera:")
            attachments[0]["fields"].append({
                "title": "Link",
                "value": link,
                "short": False
            })
            attachments[0]["image_url"] = link
        else:
            message = message.format(type=" Link :link:")
            attachments[0]["fields"].append({
                "title": "Link",
                "value": link,
                "short": False
            })
    elif location != "":
        message = message.format(type=" Location :round_pushpin:")
        coordinate = location.replace(";", ",")

        # Reverse geocoding
        address = reverse_geocoding(coordinate)
        if address is not None:
            attachments[0]["fields"].append({
{'fraction_non_alphanumeric': 0.14153029632905795, 'fraction_numerical': 0.01901813356921716, 'mean_word_length': 2.2376521116678596, 'pattern_counts': {'":': 28, '<': 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': '4236960', 'n_tokens_mistral': 1460, 'n_tokens_neox': 1402, 'n_words': 287}