Exemple #1
0
 def __init__(self):
     self._all_votes = SFXVote.db().all()
     self._all_users = User.db().all()
     self._all_cmds = Command.db().all()
     # self._user_code = UserCode.db().all()
     self._all_sfxs = SoundeffectsLibrary.fetch_soundeffect_samples()
     self.command_users = self._setup_command_users()
Exemple #2
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()
Exemple #3
0
    def _set_bet_and_wager(self):
        self.bet = 1
        self.wager = []

        for arg in self.args:
            if arg in SoundeffectsLibrary.soundeffects_only():
                self.wager.append(arg)

            if self._is_valid_bet(arg):
                if isinstance(arg, int):
                    self.bet = arg
                elif arg.endswith("s"):
                    self.bet = int(arg[:-1])
                else:
                    self.bet = int(arg)
    def purge_theme_songs():
        themes = SoundeffectsLibrary.fetch_theme_songs()

        to_delete = []
        for cmd in Command.db().all():
            name = cmd["name"]
            if name in themes:

                print(f"ILLEGAL COMMAND: {name}")
                command = Command(name)
                illegal_users = command.users()
                for user in illegal_users:
                    command.unallow_user(user)
                to_delete.append(cmd.doc_id)
        Command.delete(to_delete)
    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"
            )
Exemple #6
0
def _remove_completed_requests():
    soundeffect_names = SoundeffectsLibrary.fetch_soundeffect_names()

    unfulfilled_requests = [
        request for request in
        SOUNDEFFECT_REQUESTS_PATH.read_text().strip().split("\n")
        if request.split()[3] not in soundeffect_names
    ]

    print(f"\n{soundeffect_names}\n")
    print(f"\n\nUnfulfilled Request: {unfulfilled_requests}\n\n")
    with open(SOUNDEFFECT_REQUESTS_PATH, "w") as f:
        if unfulfilled_requests:
            f.write("\n".join(unfulfilled_requests) + "\n")
        else:
            f.write("")
Exemple #7
0
 def __init__(self, name, inital_cost=1):
     self.name = name
     self.permitted_users = []
     self.inital_health = 3
     self.inital_cost = inital_cost
     self.is_theme_song = self.name in SoundeffectsLibrary.fetch_theme_songs()
Exemple #8
0
 def _is_command(self, command):
     return command in SoundeffectsLibrary.fetch_soundeffect_names()