Example #1
0
    def share(self):
        if not self.command in SoundeffectsLibrary.fetch_soundeffect_names():
            raise ValueError(f"!{self.command} invalid command")

        command = Command(name=self.command)
        command_cost = command.cost()
        user_cool_points = User(self.user).cool_points()

        if self.user in STREAM_GODS:
            perm_result = command.allow_user(self.friend)
            return f"{self.user} shared {perm_result}"

        elif user_cool_points >= command_cost:
            perm_result = command.allow_user(self.friend)
            if perm_result:
                print("\nWe have a Perm Result")
                User(self.user).update_cool_points(-command_cost)
                command.increase_cost(command_cost * 2)
                return f"{self.user} shared {perm_result}"
            else:
                print("\nWe NOOOOO have a Perm Result")
                return f"{self.user} cannot add permissions"

        else:
            return f"@{self.user} Not enough cool_points ({user_cool_points}/{command_cost}) to share !{self.command} with @{self.friend}"
Example #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()
Example #3
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("")
Example #4
0
    def _buy_sfx(self, user: User, effect: str) -> PurchaseReceipt:
        current_cool_points = user.cool_points()

        if effect not in SoundeffectsLibrary.fetch_soundeffect_names():
            return PurchaseReceipt(
                user=user.name,
                sfx=effect,
                result=PurchaseResult.InvalidSFX,
                cool_points=current_cool_points,
            )

        command = Command(effect)
        command_cost = command.cost()

        if Command(effect).allowed_to_play(user.name):
            return PurchaseReceipt(
                user=user.name,
                sfx=effect,
                cost=command_cost,
                result=PurchaseResult.AlreadyOwn,
                cool_points=current_cool_points,
            )

        if current_cool_points >= command_cost:
            user.update_cool_points(-command_cost)
            command.allow_user(user.name)
            command.increase_cost()

            return PurchaseReceipt(
                user=user.name,
                sfx=effect,
                cool_points=current_cool_points,
                result=PurchaseResult.SuccessfulPurchase,
                cost=command_cost,
            )
        else:
            return PurchaseReceipt(
                user=user.name,
                sfx=effect,
                cool_points=current_cool_points,
                result=PurchaseResult.TooPoor,
                cost=command_cost,
            )
Example #5
0
import shutil
from pathlib import Path

# import wikipedia
import pywikibot

from chat_thief.audioworld.soundeffects_library import SoundeffectsLibrary

all_sfx = SoundeffectsLibrary.fetch_soundeffect_names()

geo_guesser_countries = [
    "botswana",
    "senegal",
    "south africa",
    "bangladesh",
    "cambodia",
    "india",
    "indonesia",
    "israel",
    "japan",
    "malaysia",
    "mongolia",
    "philippines",
    "russia",
    "singapore",
    "taiwan",
    "thailand",
    "belgium",
    "bulgaria",
    "croatia",
    "denmark",
Example #6
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")
Example #7
0
 def _is_command(self, command):
     return command in SoundeffectsLibrary.fetch_soundeffect_names()