def give(self) -> str:
        parser = CommandParser(
            user=self.user,
            command=self.command,
            args=self.args,
            allow_random_sfx=True,
            allow_random_user=True,
        ).parse()

        if parser.target_command == "random":
            sfx_choices = random.choice(User(self.user).commands(),
                                        1) - [self.user]
            parser.target_sfx = sfx_choices[0]
            print(f"Choosing Random Command: {parser.target_command}")

        if parser.target_user == "random":
            command = Command(parser.target_sfx)
            parser.target_user = find_random_user(
                blacklisted_users=[command.users()] + [self.user])

        if parser.target_user is None:
            raise ValueError("We didn't find a user to give to")

        print(
            f"Attempting to give: !{parser.target_sfx} @{parser.target_user}")

        # This interface needs to call Command SFX
        return CommandGiver(
            user=self.user,
            command=parser.target_sfx,
            friend=parser.target_user,
        ).give()
示例#2
0
    def share(self):
        parser = CommandParser(
            user=self.user,
            command=self.command,
            args=self.args,
            allow_random_sfx=True,
            allow_random_user=True,
        ).parse()

        if parser.target_sfx == "random":
            commands = User(self.user).commands()
            parser.target_sfx = random.sample(commands, 1)[0]

        if parser.target_user == "random" or parser.target_user is None:
            if parser.target_sfx:
                parser.target_user = find_random_user(
                    blacklisted_users=Command(parser.target_sfx).users())

        if parser.target_user and parser.target_sfx:
            return CommandSharer(self.user, parser.target_sfx,
                                 parser.target_user).share()
        else:
            return f"Error Sharing - Command: {parser.target_sfx} | User: {parser.target_user}"