Continuing the refactoring

This commit is contained in:
Rafael Vargas
2023-02-19 11:28:33 -03:00
parent 7a5d76ffd3
commit 72043c4475
26 changed files with 369 additions and 502 deletions

View File

@@ -1,9 +1,11 @@
from abc import ABC, abstractmethod
from threading import Lock
from typing import Union
from discord.ext.commands import Context
from discord import Guild, Interaction
from Music.Playlist import Playlist
from Music.Song import Song
from Parallelism.ProcessInfo import PlayerInfo
from Parallelism.Commands import VCommands
class AbstractPlayersManager(ABC):
@@ -11,19 +13,33 @@ class AbstractPlayersManager(ABC):
pass
@abstractmethod
def setPlayerInfo(self, guild: Guild, info: PlayerInfo):
def sendCommandToPlayer(self, command: VCommands, guild: Guild, forceCreation: bool = False, context: Union[Context, Interaction] = None):
"""If the forceCreation boolean is True, then the context must be provided for the Player to be created"""
pass
@abstractmethod
def getOrCreatePlayerInfo(self, guild: Guild, context: Union[Context, Interaction]) -> PlayerInfo:
def getPlayerPlaylist(self, guild: Guild) -> Playlist:
"""If there is a player process for the guild, then return the playlist of the guild"""
pass
@abstractmethod
def resetProcess(self, guild: Guild, context: Context) -> None:
def getPlayerLock(self, guild: Guild) -> Lock:
"""If there is a player process for the guild, then return the lock of the guild"""
pass
@abstractmethod
def getRunningPlayerInfo(self, guild: Guild) -> PlayerInfo:
def verifyIfPlayerExists(self, guild: Guild) -> bool:
"""Returns if a player for the guild exists"""
pass
@abstractmethod
def createPlayerForGuild(self, guild: Guild, context: Union[Context, Interaction]) -> None:
"""With the context information of a guild create a internal player for the guild"""
pass
@abstractmethod
def resetPlayer(self, guild: Guild, context: Context) -> None:
"""Tries to reset the player of the guild"""
pass
@abstractmethod