# AUTOGENERATED! DO NOT EDIT! File to edit: notebooks/02_constants.ipynb (unless otherwise specified).

__all__ = ['SCRIPT_DIR', 'CONFIG', 'BOT_NAME', 'BOT_INSTRUCTIONS', 'EXAMPLE_CONVOS', 'DISCORD_BOT_TOKEN',
           'DISCORD_CLIENT_ID', 'OPENAI_API_KEY', 'ALLOWED_SERVER_IDS', 'SERVER_TO_MODERATION_CHANNEL',
           'BOT_INVITE_URL', 'MODERATION_VALUES_FOR_BLOCKED', 'MODERATION_VALUES_FOR_FLAGGED',
           'SECONDS_DELAY_RECEIVING_MSG', 'MAX_THREAD_MESSAGES', 'ACTIVATE_THREAD_PREFX', 'INACTIVATE_THREAD_PREFIX',
           'MAX_CHARS_PER_REPLY_MSG']

# Cell
from dotenv import load_dotenv
load_dotenv()

# Internal Cell
import os
import dacite
import yaml
from typing import Dict, List

# Internal Cell
from .base import Config

# Cell
# load config.yaml
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
CONFIG: Config = dacite.from_dict(
    Config, yaml.safe_load(open(os.path.join(SCRIPT_DIR, 'config.yaml'), 'r'))
)

BOT_NAME = CONFIG.name
BOT_INSTRUCTIONS = CONFIG.instructions
EXAMPLE_CONVOS = CONFIG.example_conversations

DISCORD_BOT_TOKEN = os.environ['DISCORD_BOT_TOKEN']
DISCORD_CLIENT_ID = os.environ['DISCORD_CLIENT_ID']
OPENAI_API_KEY = os.environ['OPENAI_API_KEY']

# Cell
ALLOWED_SERVER_IDS: List[int] = []

# Internal Cell
server_ids = os.environ['ALLOWED_SERVER_IDS'].split(',')
for s in server_ids:
    ALLOWED_SERVER_IDS.append(int(s))

# Cell
SERVER_TO_MODERATION_CHANNEL: Dict[int, int] = {}

# Internal Cell
server_channels = os.environ.get('SERVER_TO_MODERATION_CHANNEL', '').split(',')
for s in server_channels:
    values = s.split(':')
    SERVER_TO_MODERATION_CHANNEL[int(values[0])] = int(values[1])

# Cell
# Send Messages, Create Public Threads, Send Messages in Threads, Manage Messages, Manage Threads, Read Message History, Use Slash Command
BOT_INVITE_URL = f'https://discord.com/api/oauth2/authorize?client_id={DISCORD_CLIENT_ID}&permissions=328565073920&scope=bot'

MODERATION_VALUES_FOR_BLOCKED = {
    'hate': 0.5,
    'hate/threatening': 0.1,
    'self-harm': 0.2,
    'sexual': 0.5,
    'sexual/minors': 0.2,
    'violence': 0.7,
    'violence/graphic': 0.8,
}

MODERATION_VALUES_FOR_FLAGGED = {
    'hate': 0.4,
    'hate/threatening': 0.05,
    'self-harm': 0.1,
    'sexual': 0.3,
    'sexual/minors': 0.1,
    'violence': 0.1,
    'violence/graphic': 0.1,
}

SECONDS_DELAY_RECEIVING_MSG = (
    3  # give a delay for the bot to respond so it can catch multiple messages
)
MAX_THREAD_MESSAGES = 200
ACTIVATE_THREAD_PREFX = '💬✅'
INACTIVATE_THREAD_PREFIX = '💬❌'
MAX_CHARS_PER_REPLY_MSG = (
    1500  # discord has a 2k limit, we just break message into 1.5k
)