Ejemplo n.º 1
0
    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()
    def test_the_1080(self):
        user = "******"
        args = ["1080"]
        subject = CommandParser(user, "dropeffect", args)
        result = subject.parse()

        assert result.target_command == "dropeffect"
        assert result.target_sfx == "1080"
        assert result.amount == 1
 def test_just_a_command(self):
     user = "******"
     args = ["!clap"]
     subject = CommandParser(user, "perms", args)
     result = subject.parse()
     assert result.target_user == None
     assert result.target_command == "perms"
     assert result.target_sfx == "clap"
     assert result.requester == user
 def test_just_a_user(self):
     user = "******"
     args = ["@artmattDank"]
     subject = CommandParser(user, "perms", args)
     result = subject.parse()
     assert result.target_user == "artmattdank"
     assert result.target_command == "perms"
     assert result.target_sfx == None
     assert result.requester == user
 def test_a_buy_random_command_when_not_allowed(self):
     user = "******"
     args = ["random"]
     subject = CommandParser(user, "buy", args, allow_random_sfx=False)
     result = subject.parse()
     assert result.target_user == None
     assert result.target_command == "buy"
     assert result.target_sfx == None
     assert result.requester == user
 def test_a_give_random_command(self):
     user = "******"
     args = ["@artmattDank", "random"]
     subject = CommandParser(user, "give", args, allow_random_sfx=True)
     result = subject.parse()
     assert result.target_user == "artmattdank"
     assert result.target_command == "give"
     assert result.target_sfx == "random"
     assert result.requester == user
 def test_transfer(self):
     user = "******"
     args = ["@artmattdank", "!clap"]
     subject = CommandParser(user, "transfer", args)
     result = subject.parse()
     assert result.target_user == "artmattdank"
     assert result.target_command == "transfer"
     assert result.target_sfx == "clap"
     assert result.requester == user
    def test_amount_with_seconds(self):
        user = "******"
        args = ["beginbot", "10s"]
        subject = CommandParser(user, "props", args)
        result = subject.parse()

        assert result.target_command == "props"
        assert result.target_user == "beginbot"
        assert result.target_sfx == None
        assert result.amount == 10
 def test_transfer_to_random_user_when_not_allowed(self):
     user = "******"
     args = ["random", "random"]
     subject = CommandParser(
         user, "transfer", args, allow_random_sfx=True, allow_random_user=False
     )
     result = subject.parse()
     assert result.target_user == None
     assert result.target_command == "transfer"
     assert result.target_sfx == "random"
     assert result.requester == user
 def test_transfer_to_random_user(self):
     user = "******"
     args = ["random", "random"]
     subject = CommandParser(
         user, "transfer", args, allow_random_sfx=True, allow_random_user=True
     )
     result = subject.parse()
     assert result.target_user == "random"
     assert result.target_command == "transfer"
     assert result.target_sfx == "random"
     assert result.requester == user
    def test_blank_means_random(self):
        user = "******"
        args = []
        subject = CommandParser(
            user, "steal", args, allow_random_sfx=True, allow_random_user=True
        )
        result = subject.parse()

        assert result.target_command == "steal"
        assert result.target_user == "random"
        assert result.target_sfx == "random"
        assert result.requester == user
Ejemplo n.º 12
0
    def props(self) -> str:
        parser = CommandParser(
            user=self.user,
            command=self.command,
            args=self.args,
            allow_random_user=True,
        ).parse()

        target_user_creator = User(parser.target_user).creator()
        user_creator = User(self.user).creator()

        target_user = parser.target_user
        top_eight = []

        if parser.target_user == "random" or parser.target_user is None:
            top_eight = [
                friend for friend in User(self.user).top_eight()
                if User(friend).creator() != self.user
            ]
            if top_eight == []:
                return f"@{self.user} You must specify a Top8 to give random props (Bots Don't count). !top8 @user"

        if target_user_creator == self.user:
            return f"You cannot props your own bot @{self.user} @{parser.target_user}"

        elif user_creator and user_creator == parser.target_user:
            return f"You cannot props your creator @{self.user} @{parser.target_user}"

        # target_user = random.sample( top_eight, 1)[0]
        return StreetCredTransfer(
            user=self.user,
            cool_person=target_user,
            top_eight=top_eight,
            amount=parser.amount,
        ).transfer()
Ejemplo n.º 13
0
    def route(self):
        if self.command == "la_libre":
            return " | ".join(LaLibre.inform())

        if self.command == "streamlords":
            return " ".join(STREAM_LORDS)

        if self.command == "streamgods":
            return " ".join(STREAM_GODS)

        if self.command == "so":
            return self._shoutout()

        if self.user in STREAM_GODS:
            parser = CommandParser(
                user=self.user, command=self.command, args=self.args
            ).parse()

            if self.command == "bankrupt":
                return User(parser.target_user).bankrupt()

            if self.command == "paperup":
                if parser.target_user:
                    return User(parser.target_user).paperup()
                else:
                    return "You need to specify who to Paperup"
Ejemplo n.º 14
0
    def build_response(self) -> Optional[str]:
        if self.user == "nightbot":
            return

        if self.user not in BLACKLISTED_LOG_USERS:
            self._logger.info(f"{self.user}: {self.msg}")
            WelcomeCommittee().welcome_new_users(self.user)

        success(f"\n{self.user}: {self.msg}")

        if self.user in STREAM_GODS:
            print(f"Oh Look we got a Stream God over here: {self.user}")
            if self.command == "curb_your_begin":
                return BreakingNews(" ".join(self.irc_msg.args), category="curb").save()

            if self.command in ["iasip", "alwayssunny"]:
                BreakingNews(" ".join(self.irc_msg.args), category="iasip").save()
                return

        parser = CommandParser(
            user=self.user, command=self.command, args=self.args
        ).parse()

        for Router in ROUTERS:
            try:
                if result := Router(self.user, self.command, self.args, parser).route():

                    # TODO: Sort out this Result Concept Better
                    if isinstance(result, Result):
                        # TODO: Update This
                        UserEvent(
                            user=self.irc_msg.user,
                            command=self.irc_msg.command,
                            msg=self.irc_msg.msg,
                            result=[],
                            # result=result,
                        ).save()
                    else:
                        UserEvent(
                            user=self.irc_msg.user,
                            command=self.irc_msg.command,
                            msg=self.irc_msg.msg,
                            result=result,
                        ).save()

                    return result
            except Exception as e:
                traceback.print_exc()
                # raise e

        if self.command in OBS_COMMANDS and self.user in STREAM_LORDS:
            print(f"executing OBS Command: {self.command}")
            return os.system(f"so {self.command}")

        if self.command in SoundeffectsLibrary.fetch_soundeffect_names():
            if self.command:
                PlaySoundeffectRequest(user=self.user, command=self.command).save()
Ejemplo n.º 15
0
    def __init__(self, user, command, args=[], parser=None):
        self.user = user
        self.command = command
        self.args = args

        if parser:
            self.parser = parser
        else:
            self.parser = CommandParser(
                user=self.user, command=self.command, args=self.args
            ).parse()
Ejemplo n.º 16
0
    def buy(self) -> Union[List, str]:
        parser = CommandParser(
            user=self.user,
            command=self.command,
            args=self.args,
            allow_random_sfx=True,
        ).parse()

        result = Buyer(user=self.user,
                       target_sfx=parser.target_sfx,
                       amount=parser.amount).buy()

        return self._format_result(result)
Ejemplo n.º 17
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}"
Ejemplo n.º 18
0
    def __init__(
        self,
        user: str,
        command: str,
        args: Optional[List[str]] = [],
        parser: Optional[Any] = None,
    ):
        self.user = user
        self.command = command
        self.args = args

        if parser:
            self.parser = parser
        else:
            self.parser = CommandParser(user=self.user,
                                        command=self.command,
                                        args=self.args).parse()
Ejemplo n.º 19
0
    def build_response(self) -> Optional[str]:
        if self.user == "nightbot":
            return

        if self.user not in BLACKLISTED_LOG_USERS:
            self._logger.info(f"{self.user}: {self.msg}")
            WelcomeCommittee().welcome_new_users(self.user)

        success(f"\n{self.user}: {self.msg}")

        if self.user in STREAM_GODS:
            print(f"Oh Look we got a Stream God over here: {self.user}")
            if self.command == "curb_your_begin":
                return BreakingNews(" ".join(self.irc_msg.args), category="curb").save()

            if self.command in ["iasip", "alwayssunny"]:
                BreakingNews(" ".join(self.irc_msg.args), category="iasip").save()
                return

        parser = CommandParser(
            user=self.user, command=self.command, args=self.args
        ).parse()

        for Router in ROUTERS:
            try:
                if result := Router(self.user, self.command, self.args, parser).route():

                    # TODO: Sort out this Result Concept Better
                    if isinstance(result, Result):
                        # TODO: Update This
                        UserEvent(
                            user=self.irc_msg.user,
                            command=self.irc_msg.command,
                            msg=self.irc_msg.msg,
                            result=[],
                            # result=result,
                        ).save()
                    else:
                        UserEvent(
                            user=self.irc_msg.user,
                            command=self.irc_msg.command,
                            msg=self.irc_msg.msg,
                            result=result,
                        ).save()

                    return result
            except Exception as e:
                traceback.print_exc()
                # raise e

        if self.command == "whylua":
            os.system(f"scene codin_and_teej")

        pack_config = {
            "teej_pack" : [],
            "dean_pack" : [],
            "erik_pack" : [],
            "vim_pack" : [],
            "pokemon_pack" : [],
            "sandstorm_pack" : [],
            "linux_pack" : [],
            "eightbit_pack" : [ "8bitmack", "8bitymca", "8bitmackintro",
                "8bitsk8erboi", "8bitmacarena", "8bitrickandmorty", "8bitimperial",
                "8bitfriday", "8bitghostbusters1", "8bitghostbuster2",
                "8bitfatbottomedgirls", "8bittoto", "8bitbitesthedust",
                "8bitchampions", "8bitbohemian", "8bitbagpipes", "8bitwreckingball",
                "8bitzelda", "8bitonemoretime", "8bitabout", "8bitblue",
                "8bithammer", "8bitafrica", "8bitrugrats", "8bitroll",
                "8bitparadise", "8bitrangers", "8bitcalifornialove" ],
            "silicon_valley_pack" : [],
            "gaming_pack" : [],
            "begin_pack" : [ "itsmedavid", "penisinspected", "bestsound",
                "beginsing", "beginvimeyes", "crack" ],
            "yacht_pack" : [],
            "luke_pack" : [ "gcc", "alpine", "xoomers", "inspiredme", "i3", "i3v2", "python" ],
            "wesley_willis_pack" : [],
            "art_matt_pack" : ["thisiscoke", "easyartmatt", "zenofartmatt", "moremore", "thisslaps"],
            "shannon_pack" : [],
            "meme_pack" : [],
            "i3_pack" : [],
            "prime_pack" : [ "primetrollsbegin", "primebegin", "primeslam", "primeagen", "primeagenpity", "begin_v_prime", "nevervim", ]
        }

        if self.command in pack_config["prime_pack"]:
            os.system(f"scene primetime")

        if self.command == "droppack" and self.user in STREAM_GODS and self.args[0] in pack_config.keys():
            sounds = pack_config[ self.args[0] ]
            for sound in sounds:
                drop_effect(parser.target_user, sound)
            return f"Dropping the {self.args[0]} Pack for {parser.target_user}"

        if self.command in OBS_COMMANDS and self.user in STREAM_LORDS:
            print(f"executing OBS Command: {self.command}")
            return os.system(f"so {self.command}")

        if self.command == "trollbegin" and User(self.user).mana() > 0:
            User(self.user).kill()
            pause = 1
            if parser.amount > 10:
                return "Trolling is the Art of Sublety"

            for _ in range(0, parser.amount):
                spin_begin(pause / parser.amount)
            return

        if self.command == "hottub" and self.user in STREAM_LORDS:
            return os.system("scene hottub")

        if self.command in SoundeffectsLibrary.fetch_soundeffect_names():
            if self.command:
                return PlaySoundeffectRequest(
                    user=self.user, command=self.command
                ).save()

        from pathlib import Path

        user_msgs_path = Path(__file__).parent.parent.joinpath("logs/user_msgs.log")
        if self.user not in BLACKLISTED_LOG_USERS:
            with open(user_msgs_path, "a") as log_file:
                log_file.write(f"{self.user}: {self.msg}\n")