from core.buddy_service import BuddyService
from core.command_alias_service import CommandAliasService
from core.db import DB
from core.decorators import instance
from core.logger import Logger
from core.lookup.pork_service import PorkService
from core.text import Text
from core.igncore import IgnCore
from core.util import Util
from modules.core.accounting.services.access_service import AccessService


# noinspection DuplicatedCode
@instance()
class OrgAliasController:
    org_prefix = {4736: "AP", 9632: "AP", 9622: "AC", 9831: "AC", 581633: "BST", 9707: "CoH", 9990: "CoH", 4637: "HAV",
                  10197: "IMP", 6093: "LCG", 4789: "MJ", 4687: "NA", 4800: "PR", 4993: "REGS", 813067: "SOTL",
                  4851: "SP", 9611: "SP", 4614: "TA", 4831: "TGNF", 6183: "TRE", 9822: "TS", 4611: "UHS",
                  5571: "UOTR", 520210: "WO", 1349649: "VR", 4826: "42", 1349647: "VR", 6332: "DRA", 848: "DRA",
                  4675: "VA", 1558530: "EoS"}

    def inject(self, registry):
        self.logger = Logger(__name__)
        self.bot: IgnCore = registry.get_instance("bot")
        self.db: DB = registry.get_instance("db")
        self.text: Text = registry.get_instance("text")
        self.util: Util = registry.get_instance("util")
        self.pork: PorkService = registry.get_instance("pork_service")
        self.org_pork: PorkService = registry.get_instance("org_pork_service")
        self.command_alias_service: CommandAliasService = registry.get_instance("command_alias_service")
        self.buddy_service: BuddyService = registry.get_instance("buddy_service")
        self.access_service: AccessService = registry.get_instance("access_service")

    def start(self):
        self.db.exec("CREATE TABLE IF NOT EXISTS org_alias(org_id int primary key not null, org_alias VARCHAR(255))")

    def get_alias(self, org_id):
        return self.org_prefix.get(org_id, "-UKN-")
