# Kemoverse - a gacha-style bot for the Fediverse.
# Copyright © 2025 Moon and contributors.

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see https://www.gnu.org/licenses/.

from fediverse_service import FediverseService
from misskey_service import MisskeyService
from pleroma_service import PleromaService


class FediverseServiceFactory:
    """Factory for creating FediverseService implementations"""
    
    @staticmethod
    def create_service(instance_type: str) -> FediverseService:
        """
        Create a FediverseService implementation based on the instance type.
        
        Args:
            instance_type: The type of instance ("misskey" or "pleroma")
        
        Returns:
            FediverseService implementation (MisskeyService or PleromaService)
            
        Raises:
            ValueError: If the instance type is not supported
        """
        instance_type = instance_type.lower()
        
        if instance_type == "misskey":
            return MisskeyService()
        elif instance_type == "pleroma":
            return PleromaService()
        else:
            raise ValueError(f"Unsupported instance type: {instance_type}")


def get_fediverse_service(instance_type: str) -> FediverseService:
    """
    Convenience function to get a FediverseService instance
    
    Args:
        instance_type: The instance type ("misskey" or "pleroma")
    """
    return FediverseServiceFactory.create_service(instance_type)