<commit_before>import logging

import aiohttp
import asyncio
import discord
import hypercorn
from hypercorn.asyncio.run import Server
from lifesaver.bot import Bot
from lifesaver.bot.storage import AsyncJSONStorage

from dog.context import Context
from dog.guild_config import GuildConfigManager
from dog.web.server import app as webapp
from dog.helpformatter import HelpFormatter

log = logging.getLogger(__name__)


async def _boot_hypercorn(app, config, *, loop):
    """Manually creates a Hypercorn server.

    Hypercorn's facilities for running a server on an already existing loop
    modify the loop in ways that make it impossible to use CTRL-C to kill the
    bot for some reason. Hypercorn does this by silently catching
    KeyboardInterrupts and setting signal handlers on the event loop, but this
    fails to work for some reason.
    """
    socket = config.create_sockets()
    server = await loop.create_server(
        lambda: Server(app, loop, config),
        backlog=config.backlog,
        sock=socket[0],
    )
    return server


class Dogbot(Bot):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, context_cls=Context, formatter=HelpFormatter(), **kwargs)
        self.session = aiohttp.ClientSession(loop=self.loop)
        self.load_all()
        self.blacklisted_storage = AsyncJSONStorage('blacklisted_users.json', loop=self.loop)
        self.guild_configs = GuildConfigManager(self)

        # webapp (quart) setup
        webapp.config.from_mapping(self.config.web['app'])
        webapp.bot = self
        self.webapp = webapp

        # http server (hypercorn) setup
        self.http_server_config = hypercorn.Config.from_mapping(self.config.web['http'])
        self.http_server = None
        self.loop.create_task(self._boot_http_server())

    def dispatch(self, event_name, *args, **kwargs):
        """Modified version of the vanilla dispatch to fit disabled_cogs."""
        discord.Client.dispatch(self, event_name, *args, **kwargs)

        ev = 'on_' + event_name
        guild = None

        # yup, this can't go wrong at all<commit_msg>Specify custom help command in __init__<commit_after>import logging

import aiohttp
import asyncio
import discord
import hypercorn
from hypercorn.asyncio.run import Server
from lifesaver.bot import Bot
from lifesaver.bot.storage import AsyncJSONStorage

from dog.web.server import app as webapp
from .context import Context
from .guild_config import GuildConfigManager
from .help import HelpCommand

log = logging.getLogger(__name__)


async def _boot_hypercorn(app, config, *, loop):
    """Manually creates a Hypercorn server.

    Hypercorn's facilities for running a server on an already existing loop
    modify the loop in ways that make it impossible to use CTRL-C to kill the
    bot for some reason. Hypercorn does this by silently catching
    KeyboardInterrupts and setting signal handlers on the event loop, but this
    fails to work for some reason.
    """
    socket = config.create_sockets()
    server = await loop.create_server(
        lambda: Server(app, loop, config),
        backlog=config.backlog,
        sock=socket[0],
    )
    return server


class Dogbot(Bot):
    def __init__(self, cfg, **kwargs):
        super().__init__(
            cfg, context_cls=Context,
            help_command=HelpCommand(dm_help=cfg.dm_help), **kwargs)

        self.session = aiohttp.ClientSession(loop=self.loop)
        self.load_all()
        self.blacklisted_storage = AsyncJSONStorage('blacklisted_users.json', loop=self.loop)
        self.guild_configs = GuildConfigManager(self)

        # webapp (quart) setup
        webapp.config.from_mapping(self.config.web['app'])
        webapp.bot = self
        self.webapp = webapp

        # http server (hypercorn) setup
        self.http_server_config = hypercorn.Config.from_mapping(self.config.web['http'])
        self.http_server = None
        self.loop.create_task(self._boot_http_server())

    def dispatch(self, event_name, *args, **kwargs):
        """Modified version of the vanilla dispatch to fit disabled_cogs."""
        discord.Client.dispatch(self, event_name, *args, **kwargs)

        ev = 'on_' + event_name
        guild = None

        # yup, this can't go wrong at all
{'fraction_non_alphanumeric': 0.08536585365853659, 'fraction_numerical': 0.00046904315196998124, 'mean_word_length': 3.3037336024217963, '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': '5763827', 'n_tokens_mistral': 1252, 'n_tokens_neox': 1193, 'n_words': 371}