<commit_before><?php

/*
 * Usage:
 * php send2slack.php "http://xx.com" "#xx" "xx" "https://xx/hook"
 */

main($argc, $argv);

function main($argc, $argv = array())
{
    try {
        $payload = [
            'channel' => $argv[2],
            'username' => $argv[3],
            'text' => '',
            'icon_emoji' => ':underage:',
        ];
        $apiUrl = $argv[1] . '/feed-item?approved=1&sent=0';
        $feeds = json_decode(file_get_contents($apiUrl), true);
        $text = 'Plop bitches (' . count($feeds) . 'links )';
        foreach ($feeds as $feed) {
            $id = $feed['id'];
            $text .= $feed['url'] . ' ' . $feed['comment'] . PHP_EOL;
            exec("curl --data \"id=$id&sent=1\" $argv[1]/update-item");
        }
        $payload['text'] .= $text;
        $sendJson = json_encode($payload);
        var_dump($payload);
        exec("curl -X POST --data-urlencode 'payload=$sendJson' $argv[4]");
    } catch (\Exception $e) {
        echo $e->getMessage() . PHP_EOL;
        die;
    }
}<commit_msg>Add stuff<commit_after><?php

/*
 * Usage:
 * php send2slack.php "http://xx.com" "#xx" "xx" "https://xx/hook"
 */

main($argc, $argv);

function main($argc, $argv = array())
{
    try {
        $payload = [
            'channel' => $argv[2],
            'username' => $argv[3],
            'text' => '',
            'icon_emoji' => ':underage:',
        ];
        $apiUrl = $argv[1] . '/feed-item?approved=1&sent=0';
        $feeds = json_decode(file_get_contents($apiUrl), true);
        $text = 'Plop bitches (*' . count($feeds) . ' links*)' . PHP_EOL;
        foreach ($feeds as $feed) {
            $id = $feed['id'];
            $text .= $feed['url'] . ' ' . $feed['comment'] . PHP_EOL;
            exec("curl --data \"id=$id&sent=1\" $argv[1]/update-item");
        }
        $payload['text'] .= $text;
        $sendJson = json_encode($payload);
        var_dump($payload);
        exec("curl -X POST --data-urlencode 'payload=$sendJson' $argv[4]");
    } catch (\Exception $e) {
        echo $e->getMessage() . PHP_EOL;
        die;
    }
}
{'fraction_non_alphanumeric': 0.21695402298850575, 'fraction_numerical': 0.008620689655172414, 'mean_word_length': 2.0319303338171264, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 2, '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': '3357434', 'n_tokens_mistral': 737, 'n_tokens_neox': 729, 'n_words': 134}