Ejemplo n.º 1
0
 def handler(self):
     if self.commandStructureCompatibility():
         if CommandConfig.insideTheCommonCommands(self.__command):
             CommandConfig.getCommonCommands().get(self.__command).get("function")(controller=self.__controller)
         elif CommandConfig.insideTheSpecialCommands(self.__controller, self.__command):
             CommandConfig.getSpecialCommands(self.__controllerName).get(self.__command).get("function")()
         else:
             Common.printNegativeText(
                 CommandStructureConstants.NO_SUCH_COMMAND_ERR)
     else:
         Common.printNegativeText(
             CommandStructureConstants.COMMAND_STRUCTURE_COMPATIBILITY_ERR)
Ejemplo n.º 2
0
    def helpCommand(**kwargs):
        from .commandConfig import CommandConfig

        controllerName = kwargs.get("controller").__name__

        commonCommands = CommandConfig.getCommonCommands()
        privateCommands = CommandConfig.getSpecialCommands(controllerName)

        for command, value in commonCommands.items():
            Common.printNotificationText(
                f"{command} -> {value.get('description')}")

        for command, value in privateCommands.items():
            Common.printNotificationText(
                f"{command} -> {value.get('description')}")
Ejemplo n.º 3
0
        def read():
            response = Connection.notificationRequest("read", {})
            notifications = response.get("notifications")

            Common.printNotificationText("Notifications:\n")

            for notification in notifications:
                if notification.get("content") is None:
                    continue

                notificationId = notification.get("id")
                date = notification.get("date")
                content = notification.get("content")

                Common.printNotificationText(
                    f"id -> {notificationId}\ndate -> {date}\ncontent -> {content}\n"
                )
Ejemplo n.º 4
0
    def newIncomingMessages():
        chatWith = programLocation.getLocationParameters().get("chatWith")

        while programLocation.getLocation(
        ) == "ChatController" and Connection.isSession():
            response = Connection.chatRequest("new-incoming-messages",
                                              {"chatWith": chatWith})

            if response.get("successful"):
                for messageSet in response.get("newIncomingMessages"):
                    sender = messageSet.get("sender")
                    date = messageSet.get("date")
                    message = messageSet.get("message")

                    Common.printChatLabelText(f"<{sender}> <{date}>: ")
                    Common.printStandartText(message)

            time.sleep(.1)
Ejemplo n.º 5
0
    def registerForm():
        form = RegisterForm()
        form.fillTheForm()

        Common.clearTerminal()

        if form.validation():
            response = Connection.registerRequest(form.getData())
            successful = response.get("successful")
            message = response.get("message")

            if successful:
                Common.printPositiveText(message)
            else:
                Common.printNegativeText(message)
        else:
            Common.printNegativeText(form.getValidationMessage())

        Common.programSleep()
Ejemplo n.º 6
0
    def stream():
        response = Connection.chatRequest("stream", {
            "chatWith":
            programLocation.getLocationParameters().get("chatWith")
        })
        successful = response.get("successful")

        if successful:
            for messageSet in response.get("stream"):
                sender = messageSet.get("sender")
                date = messageSet.get("date")
                message = messageSet.get("message")

                if sender == "__session__":
                    Common.printChatLabelText(f"<You> <{date}>: ")
                    Common.printStandartText(message)
                else:
                    Common.printChatLabelText(f"<{sender}> <{date}>: ")
                    Common.printStandartText(message)
        else:
            Common.printNegativeText(response.get("message"))
Ejemplo n.º 7
0
    def __sendMessage(message):
        receiver = programLocation.getLocationParameters().get("chatWith")

        response = Connection.chatRequest("send-message", {
            "receiver": receiver,
            "message": message
        })

        if response.get("successful"):
            date = datetime.now().strftime("%d/%m/%Y %H:%M:%S")

            Common.printChatLabelText(f"<You> <{date}>: ")
            Common.printStandartText(message)
        else:
            Common.printNegativeText(response.get("message"))
Ejemplo n.º 8
0
        def deleteOne():
            try:
                notificationId = int(input("Notification Id -> "))
            except ValueError:
                Common.printNegativeText("Notification id must be integer")

                return

            response = Connection.notificationRequest("delete-one",
                                                      {"id": notificationId})
            successful = response.get("successful")
            message = response.get("message")

            if successful:
                Common.printPositiveText(message)
            else:
                Common.printNegativeText(message)
Ejemplo n.º 9
0
 def clear():
     Common.clearTerminal()
     ChatController.getViewTitles()
     ChatController.stream()
Ejemplo n.º 10
0
 def getViewTexts():
     Common.clearTerminal()
     Common.printStandartText(ViewTextConstants.ACCESS_TITLE)
     Common.printStandartText(ViewTextConstants.ACCESS_SUBTITLE)
Ejemplo n.º 11
0
 def getViewTitles():
     Common.clearTerminal()
     Common.printStandartText(ViewTextConstants.NOTIFICATION_TITLE)
Ejemplo n.º 12
0
 def clearCommand(**kwargs):
     Common.clearTerminal()
     kwargs.get("controller").clear()
Ejemplo n.º 13
0
 def clear():
     Common.clearTerminal()
     LobbyController.getViewTitles()
Ejemplo n.º 14
0
    def loginForm():
        form = LoginForm()
        form.fillTheForm()

        Common.clearTerminal()

        if form.validation():
            response = Connection.loginRequest(form.getData())
            successful = response.get("successful")
            message = response.get("message")

            if successful:
                Common.printPositiveText(message)
                Common.programSleep()

                LobbyView.view()
            else:
                Common.printNegativeText(message)
        else:
            Common.printNegativeText(form.getValidationMessage())

        Common.programSleep()
Ejemplo n.º 15
0
 def getViewTitles():
     Common.clearTerminal()
     Common.printStandartText(
         f"Chat area with {programLocation.getLocationParameters().get('chatWith')}, say /help for help\n"
     )
Ejemplo n.º 16
0
 def clear():
     Common.clearTerminal()
     ProfileController.getViewTitles()
Ejemplo n.º 17
0
        def whoami():
            response = Connection.profileRequest("whoami", {}).get("whoami")

            Common.printNotificationText(
                f"Username -> {response.get('username')}\nEmail -> {response.get('email')}"
            )
Ejemplo n.º 18
0
 def getViewTitles():
     Common.clearTerminal()
     Common.printStandartText(ViewTextConstants.REGISTER_TITLE)
Ejemplo n.º 19
0
 def clear():
     Common.clearTerminal()
     NotificationController.getViewTitles()