<commit_before>#!/usr/bin/env python3

import config
import sheets_api

import requests
from flask import Flask, request, redirect

import json


app = Flask(__name__)


def send_to_group(message):
    headers = {'content-type': 'application/json; charset=utf-8'}
    to_api = json.dumps({'bot_id': config.BOT_ID, 'text': message})
    resp = requests.post(config.API_URL, to_api, headers=headers)
    print(to_api, repr(resp.text), resp.status_code)


def summary_for_name(name):
    rows = sheets_api.worksheet_keys_to_rows(config.WORKSHEET_KEYS_TO_SCRAPE)
    summary = sheets_api.summary_for_name(rows, name)
    return summary or 'Sorry, no match found for "%s".' % name


@app.route('/', methods=['POST'])
def posted():
    data = request.get_json()
    text = data['text']
    clean = text.lower().strip()
    if clean.startswith(config.COMMAND_PREFIX):
        split_point = len(config.COMMAND_PREFIX)
        query = text[split_point:].strip()
        print('Searching:', repr(query))
        message = 'Searching for "%s"...' % query
        send_to_group(message)
        print('Sent message')
        print(repr(summary_for_name(query)))
        send_to_group(summary_for_name(query))
        print('Sent final')
        return ''
    else:
        print('Ignored:  ', repr(text))
        return ''


@app.route('/', methods=['GET'])
def about_me():
    return redirect(config.INDEX_REDIRECT_URL)


if __name__ == '__main__':
    app.run(debug=True)<commit_msg>Remove debug lines<commit_after>#!/usr/bin/env python3

import config
import sheets_api

import requests
from flask import Flask, request, redirect

import json


app = Flask(__name__)


def send_to_group(message):
    headers = {'content-type': 'application/json; charset=utf-8'}
    to_api = json.dumps({'bot_id': config.BOT_ID, 'text': message})
    resp = requests.post(config.API_URL, to_api, headers=headers)
    print(to_api, repr(resp.text), resp.status_code)


def summary_for_name(name):
    rows = sheets_api.worksheet_keys_to_rows(config.WORKSHEET_KEYS_TO_SCRAPE)
    summary = sheets_api.summary_for_name(rows, name)
    return summary or 'Sorry, no match found for "%s".' % name


@app.route('/', methods=['POST'])
def posted():
    data = request.get_json()
    text = data['text']
    clean = text.lower().strip()
    if clean.startswith(config.COMMAND_PREFIX):
        split_point = len(config.COMMAND_PREFIX)
        query = text[split_point:].strip()
        print('Searching:', repr(query))
        message = 'Searching for "%s"...' % query
        send_to_group(message)
        send_to_group(summary_for_name(query))
        return ''
    else:
        print('Ignored:  ', repr(text))
        return ''


@app.route('/', methods=['GET'])
def about_me():
    return redirect(config.INDEX_REDIRECT_URL)


if __name__ == '__main__':
    app.run(debug=True)
{'fraction_non_alphanumeric': 0.1404494382022472, 'fraction_numerical': 0.0014044943820224719, 'mean_word_length': 3.716887417218543, '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': '2171549', 'n_tokens_mistral': 962, 'n_tokens_neox': 942, 'n_words': 192}