Exemplo n.º 1
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()
Exemplo n.º 2
0
    def guess_pokemon(cls, user, guess):
        pokemon = cls.MYSTERY_POKEMON_PATH.read_text()

        print(f"@{user} guessed {guess}")

        if guess == pokemon:
            cls.MYSTERY_POKEMON_PATH.unlink()
            guess_count = cls.guesses()
            cls.GUESSES_PATH.unlink()

            result = f"{user} Won! {pokemon} - Beating {guess_count} Other People"
            prize = None

            if user not in STREAM_GODS:
                prize = BeginFund(target_user=user).dropeffect()

                result += f" | {prize}"

            if "TEST_MODE" not in os.environ:
                soundfile = SoundeffectsLibrary.find_sample("pokewin")
                AudioPlayer.play_sample(soundfile.resolve(),
                                        notification=False)

            Notification(f"{user} won: {guess}").save()
            return result
        else:
            with open(cls.GUESSES_PATH, "a") as f:
                f.write(f"{user}: {guess}\n")
            return f"@{user} YOU WERE WRONG"
Exemplo n.º 3
0
    def whos_that_pokemon(cls):
        if cls.MYSTERY_POKEMON_PATH.exists():
            return "Already a Guess in Progress!"

        if "TEST_MODE" not in os.environ:
            soundfile = SoundeffectsLibrary.find_sample("pokewho")
            AudioPlayer.play_sample(soundfile.resolve())

        pokemon = random.sample(POKEMON_NAMES, 1)[0]

        if "TEST_MODE" not in os.environ:
            soundfile = SoundeffectsLibrary.find_sample(pokemon)
            AudioPlayer.play_sample(soundfile.resolve(), notification=False)

        with open(cls.MYSTERY_POKEMON_PATH, "w") as f:
            f.write(pokemon)

        return "Guess Which Pokemon This Is!!!"
Exemplo n.º 4
0
    def replay(cls):
        print("Replaying Pokemon")

        if "TEST_MODE" not in os.environ:
            pokemon = cls.MYSTERY_POKEMON_PATH.read_text()
            soundfile = SoundeffectsLibrary.find_sample(pokemon)
            AudioPlayer.play_sample(soundfile.resolve(), notification=False)

        return "Who's that Pokemon"