#!/usr/bin/env python3
# -*- coding: utf-8 -*-
###################################################
#........../\./\...___......|\.|..../...\.........#
#........./..|..\/\.|.|_|._.|.\|....|.c.|.........#
#......../....../--\|.|.|.|i|..|....\.../.........#
#        Mathtin (c)                              #
###################################################
#   Author: Daniel [Mathtin] Shiko                #
#   Copyright (c) 2020 <wdaniil@mail.ru>          #
#   This file is released under the MIT license.  #
###################################################

__author__ = "Mathtin"

import logging.config
import util

BOT_NAME = "MC Manager"

EGG_DONE_MESSAGE = 'change this part'

LOGGER_CONFIG = { 
    "version": 1,
    "disable_existing_loggers": False,
    "formatters": {
        "standard": { 
            "format": "%(asctime)s [%(levelname)s] %(name)s: %(message)s"
        },
    },
    "handlers": { 
        "console": { 
            "level": "INFO",
            "formatter": "standard",
            "class": "logging.StreamHandler",
            "stream": "ext://sys.stderr",
        },
        "file": { 
            "level": "INFO",
            "formatter": "standard",
            "class": "logging.handlers.RotatingFileHandler",
            "filename": "mc-discord-bot.log",
            "maxBytes": 1024 * 1024 * 10,
            "backupCount": "3"
        },
        "discord-channel": { 
            "level": "WARN",
            "formatter": "standard",
            "()": util.DiscordBotLogHandler,
            "bot": BOT_NAME
        },
    },
    "loggers": {
        "mc-discord-bot": {
            "handlers": ["console","file", "discord-channel"],
            "level": "INFO"
        },
        "manager-hooks": {
            "handlers": ["console","file", "discord-channel"],
            "level": "INFO"
        },
        "database": {
            "handlers": ["console","file", "discord-channel"],
            "level": "INFO"
        }
    } 
}

channels = {

    # Special

    # "log": 0,
    "error": 0,
    "control": 1,


    # User defined

    "profile": 1
}

hooks = {
    "init": "manager.init",

    "message": {
        "profile": {
            "new": "manager.new_profile",
            "edit": "manager.edit_profile",
            "delete": "manager.delete_profile"
        }
    },

    "member": {
        "remove": "manager.user_left"
    },

    "control": {
        "prefix": "!",
        "commands": {
            "send": "manager.send_to_sink",
            "ping": "manager.ping",
            "reload": "manager.reload",
            "sync": "manager.sync",
            "db": "manager.show_db",
            "pdb": "manager.show_persist_db",
            "pdb-add": "manager.add_persist_profile",
            "pdb-rm": "manager.remove_persist_profile",
            "profile": "manager.get_profile",
            "rank-add": "manager.add_rank",
            "rank-rm": "manager.remove_rank",
            "rank-get": "manager.get_rank",
            "rank": "manager.show_ranked_users",
            "ranks": "manager.show_ranks"
        }
    }
}

roles = {
    "admin": ["Admin"]
}

manager = {
    "whitelist": {
        "upload": False,
        "reload": False,
        "servers": ["00000000", "00000001"]
    },

    "rank": {
        "upload": False,
        "reload": False,
        "servers": {
            "00000000": "spigot",
            "00000001": "ftbutilities"
        }
    },

    "profile": {
        "update": {
            "old": {
                "delete": False
            }
        },
        "invalid": {
            "ign": {
                "delete": False,
                "dm": False
            },
            "duplicate": {
                "delete": False,
                "dm": False
            },
            "default": {
                "delete": False,
                "dm": False
            },
        },
        "deprecated": {
            "delete": False,
            "whitelist": False
        },
        "format": {
            "require": ["age", "country"],
            "filter": []
        }
    }
}

db = {
    "persist": {
        "path": "persist_whitelist.json",
        "tables": ["root"],
        "indexes": {
            "root": ["ign"]
        }
    },
    "dynamic": {
        "tables": ["valid", "invalid", "deprecated"],
        "indexes": {
            "valid": ["msg_id", "ign"],
            "invalid": ["msg_id"],
            "deprecated": ["msg_id", "ign"]
        }
    },
    "ranks": {
        "path": "ranks.json",
        "tables": ["admin", "supporter"],
        "indexes": {
            "admin": ["ign"],
            "supporter": ["ign"]
        }
    }
}
