<commit_before>'''
Provides commands to the xkcd system
'''
from stickord.helpers.xkcd_api import get_random, get_by_id, print_comic, get_recent
from stickord.registry import Command

@Command('xkcd', category='xkcd')
async def get_comic(cont, _mesg):
    ''' Search for a comic by id, if no id is provided it will post a random comic. '''
    if cont:
        comic_id = int(cont[0])
        comic = await get_by_id(comic_id)
        return await print_comic(comic)

    comic = await get_random()
    return await print_comic(comic)

@Command('newxkcd', category='xkcd')
async def get_latest_comic(_cont, _mesg):
    ''' Posts the latest xkcd comic. '''
    comic = await get_recent()
    return await print_comic(comic)<commit_msg>Fix crash on invalid int<commit_after>'''
Provides commands to the xkcd system
'''
from stickord.helpers.xkcd_api import get_random, get_by_id, print_comic, get_recent
from stickord.registry import Command

@Command('xkcd', category='xkcd')
async def get_comic(cont, _mesg):
    ''' Search for a comic by id, if no id is provided it will post a random comic. '''
    if cont:
        try:
            comic_id = int(cont[0])
            comic = await get_by_id(comic_id)
            return await print_comic(comic)
        except ValueError:
            pass

    comic = await get_random()
    return await print_comic(comic)

@Command('newxkcd', category='xkcd')
async def get_latest_comic(_cont, _mesg):
    ''' Posts the latest xkcd comic. '''
    comic = await get_recent()
    return await print_comic(comic)
{'fraction_non_alphanumeric': 0.10077519379844961, 'fraction_numerical': 0.0012919896640826874, 'mean_word_length': 3.6516516516516515, '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': '3484088', 'n_tokens_mistral': 511, 'n_tokens_neox': 512, 'n_words': 155}