<commit_before>from pathlib import Path
from random import choice, random
from typing import List, Tuple, Union

from discord import File

from bot import HTTPStatusError, SessionManager
from core.nsfw_core import get_lewd
from data_manager import DataManager


async def wolke_image(session_manager: SessionManager, key: str,
                      type_: str) -> str:
    """
    Search wolke api for image by type.
    :param session_manager: the SessionManager instance.
    :param key: the api key.
    :param type_: the type of the image.
    :return: the image url if found else an error message.
    """
    url = 'https://staging-api.ram.moe/images/random?'
    header = {'Authorization': key}
    params = {'type': type_}
    try:
        js = await session_manager.get_json(
            url, params,
            headers=header
        )
    except HTTPStatusError as e:
        return f'Sorry, something went wrong with the Wolke api.\n{e}'
    else:
        img = js.get('url', None)
        return img or 'Sorry, nothing found.'


async def random_picture(files: List[Path], tags: Tuple[str],
                         session_manager: SessionManager,
                         data_manager: DataManager) -> Union[File, str]:
    """
    Returns a random file from local and safebooru with safebooru tags.
    :param files: list of local files.
    :param tags: a tuple of safebooru tags.
    :param session_manager: the SessionManager.
    :param data_manager: the data manager.
    :return: a random image
    """
    file = File(str(choice(files)))
    if random() < 0.5:
        return file<commit_msg>switch to new api end point for wolke api<commit_after>from pathlib import Path
from random import choice, random
from typing import List, Tuple, Union

from discord import File

from bot import HTTPStatusError, SessionManager
from core.nsfw_core import get_lewd
from data_manager import DataManager


async def wolke_image(session_manager: SessionManager, key: str,
                      type_: str) -> str:
    """
    Search wolke api for image by type.
    :param session_manager: the SessionManager instance.
    :param key: the api key.
    :param type_: the type of the image.
    :return: the image url if found else an error message.
    """
    url = 'https://staging.weeb.sh/images/random?'
    header = {'Authorization': f'Bearer {key}'}
    params = {'type': type_}
    try:
        js = await session_manager.get_json(
            url, params,
            headers=header
        )
    except HTTPStatusError as e:
        return f'Sorry, something went wrong with the Wolke api.\n{e}'
    else:
        img = js.get('url', None)
        return img or 'Sorry, nothing found.'


async def random_picture(files: List[Path], tags: Tuple[str],
                         session_manager: SessionManager,
                         data_manager: DataManager) -> Union[File, str]:
    """
    Returns a random file from local and safebooru with safebooru tags.
    :param files: list of local files.
    :param tags: a tuple of safebooru tags.
    :param session_manager: the SessionManager.
    :param data_manager: the data manager.
    :return: a random image
    """
    file = File(str(choice(files)))
    if random() < 0.5:
        return file
{'fraction_non_alphanumeric': 0.0872093023255814, 'fraction_numerical': 0.0012239902080783353, 'mean_word_length': 2.5962596259625963, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '2923426', 'n_tokens_mistral': 932, 'n_tokens_neox': 914, 'n_words': 346}