from src.repositories.chat.core import getChatStatus
from ...typings import Context
from .common.base import BaseTask


class SetChatOffTask(BaseTask):
    def __init__(self):
        super().__init__()
        self.name = 'setChatOff'
        self.delayBeforeStart = 0.5
        self.delayAfterComplete = 0.5

    # TODO: add unit tests
    def shouldIgnore(self, context: Context) -> bool:
        (_, chatIsOn) = getChatStatus(context['ng_screenshot'])
        return not chatIsOn

    def do(self, context: Context) -> Context:
        # ponytail: Enter after SayTask already returns Tibia to Chat Off.
        return context

    def did(self, context: Context) -> bool:
        (_, chatIsOn) = getChatStatus(context['ng_screenshot'])
        return not chatIsOn
