mirror of
https://github.com/iio612/DEFENDER.git
synced 2026-02-13 19:24:23 +00:00
29 lines
945 B
Python
29 lines
945 B
Python
from typing import TYPE_CHECKING, Optional
|
|
from .unreal6 import Unrealircd6
|
|
from .inspircd import Inspircd
|
|
from .interface import IProtocol
|
|
|
|
if TYPE_CHECKING:
|
|
from core.irc import Irc
|
|
|
|
class ProtocolFactorty:
|
|
|
|
def __init__(self, uplink: 'Irc'):
|
|
self.__Config = uplink.Config
|
|
self.__uplink = uplink
|
|
|
|
def get(self) -> Optional[IProtocol]:
|
|
|
|
protocol = self.__Config.SERVEUR_PROTOCOL
|
|
|
|
match protocol:
|
|
case 'unreal6':
|
|
self.__uplink.Logs.debug(f"[PROTOCOL] {protocol} has been loaded")
|
|
return Unrealircd6(self.__uplink)
|
|
case 'inspircd':
|
|
self.__uplink.Logs.debug(f"[PROTOCOL] {protocol} has been loaded")
|
|
return Inspircd(self.__uplink)
|
|
case _:
|
|
self.__uplink.Logs.critical(f"[PROTOCOL ERROR] This protocol name ({protocol} is not valid!)")
|
|
raise Exception("Unknown protocol!")
|