<commit_before><?php

///////////////////////////////////////////////////////////
// config
///////////////////////////////////////////////////////////

include __DIR__.'/vendor/autoload.php';
use Discord\DiscordCommandClient;
use Discord\Parts\User\Game;
use Discord\Parts\Embed\Embed;
use Discord\Parts\Embed\Author;
use Discord\Parts\Embed\Image;
use Discord\Parts\Embed\Footer;
use Discord\Parts\Embed\Field;
use Discord\Helpers\Collection;
use Carbon\Carbon;


include_once __DIR__.'/env_stuff.php';
include __DIR__.'/kaomoji.php';
include __DIR__.'/definitions.php';
include __DIR__.'/util_fns.php';

$starttime = Carbon::now();
$defs      = new Definitions(__DIR__.'/definitions.json');
$imgs      = new Definitions(__DIR__.'/img_urls.json');
$cities    = new Definitions(__DIR__.'/cities.json');
$help      = [];


$discord = new DiscordCommandClient([
    'token'              => get_thing('token'),
    'prefix'             => ';',
    'defaultHelpCommand' => false,
    'name'               => 'benbot',
    'discordOptions'     => [
        'pmChannels'  => true,
    ],
]);


$game = $discord->factory(Game::class, [
    'name' => ';help',
]);


$discord->on('ready', function($discord) use ($game, $defs, $imgs, $starttime) {
    $discord->updatePresence($game);

    $discord->on('message', function($msg, $args) use ($defs, $imgs) {
        // for stuff that isn't a command
        $text = $msg->content;
        $gen = char_in($text);
        $first_char = $gen->current();

        if ($first_char == ';') {

            for ($qu = "", $gen->next(); $gen->current() != " " && $gen->valid(); $gen->next())
                $qu .= $gen->current();
            $qu = strtolower($qu);
            if ($defs->get($qu, true))
                send($msg, "**$qu**: " . $defs->get($qu));
            if ($imgs->get($qu, true)) {
                $imgfile = $imgs->get($qu);
                $msg->channel->sendFile(__DIR__."/uploaded_images/$imgfile", $imgfile, $qu);
            }

        } else {

            if (is_dm($msg)) {
                if (!$msg->author->bot)
                    send($msg, ask_cleverbot(implode(' ', $args)));
            }
        }
    });

    $discord
        ->guilds->get('id','289410862907785216')
        ->channels->get('id','289611811094003715')
        ->sendMessage("<@193011352275648514>, bot started successfully");

    $starttime = Carbon::now();

});




///////////////////////////////////////////////////////////
// commands
///////////////////////////////////////////////////////////





///////////////////////////////////////////////////////////
$discord->registerCommand('hi', [
    'hey',
    'hello',
    'wussup',
    'soup',
], [
    'description' => 'greeting',
    'aliases' => [
        'Hi',
        'Hello',
        'hello',
        'henlo',
        'Henlo',
    ],
]);






///////////////////////////////////////////////////////////
$discord->registerCommand('http', function($msg, $args) use ($discord) {
    $url = "http://api.icndb.com/jokes/random1";
    $result = $discord->http->get($url)->then(function($stff) {
        var_dump($stff);
    }, function ($e) {
        $e->getMessage();
    });
    // print_r($result->result);
}, [
    'description' => 'test',
    'usage' => 'd',
]);


///////////////////////////////////////////////////////////
$time = $discord->registerCommand('time', function($msg, $args) use ($cities, $discord) {
    $url = "http://api.geonames.org/timezoneJSON?username=benharri";
    if (count($args) == 0) {
        // lookup the person's time or tell them to save their time<commit_msg>send msg ;http<commit_after><?php

///////////////////////////////////////////////////////////
// config
///////////////////////////////////////////////////////////

include __DIR__.'/vendor/autoload.php';
use Discord\DiscordCommandClient;
use Discord\Parts\User\Game;
use Discord\Parts\Embed\Embed;
use Discord\Parts\Embed\Author;
use Discord\Parts\Embed\Image;
use Discord\Parts\Embed\Footer;
use Discord\Parts\Embed\Field;
use Discord\Helpers\Collection;
use Carbon\Carbon;


include_once __DIR__.'/env_stuff.php';
include __DIR__.'/kaomoji.php';
include __DIR__.'/definitions.php';
include __DIR__.'/util_fns.php';

$starttime = Carbon::now();
$defs      = new Definitions(__DIR__.'/definitions.json');
$imgs      = new Definitions(__DIR__.'/img_urls.json');
$cities    = new Definitions(__DIR__.'/cities.json');
$help      = [];


$discord = new DiscordCommandClient([
    'token'              => get_thing('token'),
    'prefix'             => ';',
    'defaultHelpCommand' => false,
    'name'               => 'benbot',
    'discordOptions'     => [
        'pmChannels'  => true,
    ],
]);


$game = $discord->factory(Game::class, [
    'name' => ';help',
]);


$discord->on('ready', function($discord) use ($game, $defs, $imgs, $starttime) {
    $discord->updatePresence($game);

    $discord->on('message', function($msg, $args) use ($defs, $imgs) {
        // for stuff that isn't a command
        $text = $msg->content;
        $gen = char_in($text);
        $first_char = $gen->current();

        if ($first_char == ';') {

            for ($qu = "", $gen->next(); $gen->current() != " " && $gen->valid(); $gen->next())
                $qu .= $gen->current();
            $qu = strtolower($qu);
            if ($defs->get($qu, true))
                send($msg, "**$qu**: " . $defs->get($qu));
            if ($imgs->get($qu, true)) {
                $imgfile = $imgs->get($qu);
                $msg->channel->sendFile(__DIR__."/uploaded_images/$imgfile", $imgfile, $qu);
            }

        } else {

            if (is_dm($msg)) {
                if (!$msg->author->bot)
                    send($msg, ask_cleverbot(implode(' ', $args)));
            }
        }
    });

    $discord
        ->guilds->get('id','289410862907785216')
        ->channels->get('id','289611811094003715')
        ->sendMessage("<@193011352275648514>, bot started successfully");

    $starttime = Carbon::now();

});




///////////////////////////////////////////////////////////
// commands
///////////////////////////////////////////////////////////





///////////////////////////////////////////////////////////
$discord->registerCommand('hi', [
    'hey',
    'hello',
    'wussup',
    'soup',
], [
    'description' => 'greeting',
    'aliases' => [
        'Hi',
        'Hello',
        'hello',
        'henlo',
        'Henlo',
    ],
]);






///////////////////////////////////////////////////////////
$discord->registerCommand('http', function($msg, $args) use ($discord) {
    $url = "http://api.icndb.com/jokes/random1";
    $result = $discord->http->get($url)->then(function($stff) {
        send($msg, $stff->value->joke);
    }, function ($e) {
        $e->getMessage();
    });
    // print_r($result->result);
}, [
    'description' => 'test',
    'usage' => 'd',
]);


///////////////////////////////////////////////////////////
$time = $discord->registerCommand('time', function($msg, $args) use ($cities, $discord) {
    $url = "http://api.geonames.org/timezoneJSON?username=benharri";
    if (count($args) == 0) {
        // lookup the person's time or tell them to save their time
{'fraction_non_alphanumeric': 0.29469739033870074, 'fraction_numerical': 0.015546918378678512, 'mean_word_length': 1.6944652206432311, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 93, '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': '384138', 'n_tokens_mistral': 2322, 'n_tokens_neox': 2191, 'n_words': 368}