Пример #1
0
    def call(self) -> Tuple[bool, int]:
        success_range = self._calc_chance_of_success()
        roll_of_the_dice = randint(0, 100)
        busted = roll_of_the_dice > success_range

        if busted:
            print("Caught Stealing!!!")
            # if self.steal_count < 1:
            #     PlaySoundeffectRequest(user="******", command="nope").save()
            User(self.thief).set_value("mana", 0)
            RapSheet(
                user=self.thief,
                action="caught_stealing",
                metadata={
                    "target_sfx": self.target_sfx,
                    "victim": self.victim
                },
            ).save()
        else:
            print("YOU GOT AWAY WITH STEALING!!!")
            if self.target_sfx_cost > EXPENSIVE_COMMAND_COST_LIMIT:
                PlaySoundeffectRequest(user="******",
                                       command="yoink").save()

        return busted, success_range
Пример #2
0
def sync_main():
    PlaySoundeffectRequest(user="******", command="openingbell").save()

    while True:
        try:
            peasants = ChatLogs().recent_stream_peasants()
            # We need to make this better
            result = drop_random_soundeffect_to_user(
                random.sample(peasants, 1)[0])
            send_twitch_msg(result)

            for peasant in peasants:
                if peasant not in BLACKLIST:
                    user = User(peasant)
                    user_karma = user.karma()
                    print(f"@{peasant} Karma: {user.karma()}")
                    user.update_street_cred(1)
                    # user.update_street_cred(1 + user_karma)
                    user.revive(3 + user_karma)

            send_twitch_msg("CoolCat CoolCat CoolCat")
            # formatted_peasants = [f"@{peasant}" for peasant in peasants]
            # send_twitch_msg(
            #     f"Squid1 Enjoy your street cred: {' '.join(formatted_peasants)} Squid4"
            # )

            # Every 5 minutes, all the chatters have a chance at some street cred
            # os.system("time make deploy")
            time.sleep(300)
        except Exception as e:
            time.sleep(30)
            if e is KeyboardInterrupt:
                raise e
            else:
                traceback.print_exc()
Пример #3
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()
Пример #4
0
def sync_main():
    while True:
        try:
            # This deletes them from the DB
            all_effects = PlaySoundeffectRequest().pop_all_off()

            for sfx in all_effects:
                command = Command(sfx["command"])
                user = User(sfx["user"])

                command_health = 5
                # command_health = command.health()

                user_mana = user.mana()
                sfx_vote = SFXVote(command.name)

                user_allowed_to_play = command.allowed_to_play(user.name)
                public_approved = sfx_vote.is_enabled()

                if user.name in STREAM_GODS:
                    soundfile = SoundeffectsLibrary.find_sample(sfx["command"])
                    if soundfile:
                        AudioPlayer.play_sample(soundfile.resolve(),
                                                sfx["notification"], user.name)
                elif not public_approved:
                    msg = f"Command: '!{command.name}' silenced: {round(sfx_vote.like_to_hate_ratio(), 2)}% Love/Hate Ratio"
                    send_twitch_msg(msg)
                    warning(msg)
                elif user_allowed_to_play and command_health > 0 and user_mana > 0:
                    soundfile = SoundeffectsLibrary.find_sample(sfx["command"])

                    print(f"WE ARE TRYING TO PLAY: {soundfile}")

                    if soundfile:
                        AudioPlayer.play_sample(soundfile.resolve(),
                                                sfx["notification"], user.name)
                        # user.update_mana(-1)
                    else:
                        warning(
                            f"Couldn't find soundfile for {sfx['command']}")
                else:
                    if user.name not in ["beginbot", "beginbotbot"]:
                        # is the soundeffect isn't a real command
                        # don't say anything
                        msg = f"Not Playing '!{command.name}' for @{user.name} | Allowed: {user_allowed_to_play} | Mana: {user_mana}"
                        send_twitch_msg(msg)
                        warning(msg)

            # time.sleep(15)
            time.sleep(1)
        except Exception as e:
            if e is KeyboardInterrupt:
                raise e
            else:
                traceback.print_exc()
Пример #5
0
    def _welcome(self, user):
        sound_effect_files = SoundeffectsLibrary.find_soundeffect_files(user)

        if sound_effect_files:
            effect = sound_effect_files[0]
            command = Command(user)
            command.update_health(1)
            PlaySoundeffectRequest(user=user, command=user).save()
        else:
            # Use non private method
            User(user)._find_or_create_user()
            send_twitch_msg(BeginFund(user).dropeffect())
    def _welcome(self, user):
        sound_effect_files = SoundeffectsLibrary.find_soundeffect_files(user)

        if sound_effect_files:
            effect = sound_effect_files[0]
            command = Command(user)
            command.update_health(1)
            PlaySoundeffectRequest(user=user, command=user).save()
        else:
            # Use non private method
            User(user)._find_or_create_user()
            send_twitch_msg(BeginFund(user).dropeffect())
            send_twitch_msg(
                f"Welcome @{user}! You need a Theme song (max 5 secs): !soundeffect YOUTUBE-URL @{user} 00:03 00:07"
            )
Пример #7
0
    def _propose(self, proposed_command=None):
        if proposed_command:
            args = self.args
        else:
            proposed_command, *args = self.args

        if proposed_command.startswith("!"):
            proposed_command = proposed_command[1:]

        proposal = Proposal(
            user=self.user, command=proposed_command, proposal=" ".join(args),
        )
        proposal.save()

        if "TEST_MODE" not in os.environ:
            # Maybe I should be able to say no notification

            PlaySoundeffectRequest(
                user="******", command="5minutes", notification=False
            ).save()

            Notification("Type !support", duration=300).save()
        return f"Thank you @{self.user} for your proposal. You have 5 minutes to get {self.SUPPORT_REQUIREMENT} supporters"
Пример #8
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")
Пример #9
0
 def test_lower_casing_command(self):
     user = "******"
     command = "WASSUP"
     subject = PlaySoundeffectRequest(user=user, command=command, notification=False)
     subject.save()
     assert subject.command == "wassup"