Esempio n. 1
0
def save_a_buncha_info(character_name):
    character = Character(name=character_name)
    morgue_db = MorgueDB(character_name)
    morgue_file = character.s3_morgue_file()
    morgue_parser = MorgueParser(morgue_file)
    try:
        runes = morgue_parser.runes()
        if runes:
            nice_runes = [rune.strip() for rune in runes.split(",")]
            morgue_db.save_stuff("SS", "runes", nice_runes)

        xl_level = fetch_xl_level(morgue_file)
        if xl_level:
            morgue_db.save_stuff("S", "xl", xl_level.strip())

        weapons = fetch_weapons(morgue_file)
        if weapons:
            morgue_db.save_stuff("SS", "weapons", weapons)

        # gods = fetch_altars(morgue_file)
        # morgue_db.save_stuff("SS", "gods", gods)

        armour = fetch_armour(morgue_file)
        if armour:
            morgue_db.save_stuff("SS", "armour", armour)
    except Exception as e:
        print(f"Error in save_a_buncha_info by we are ok: {e}")
Esempio n. 2
0
def process_event(event):
    morgue_event = MorgueEvent.from_event(event)

    if morgue_event.command == "!h?":
        return print_the_help()

    # Elif Island
    msg = None
    if morgue_event.is_character_command():
        print("A single Character Command!")
        character = Character(name=morgue_event.character)
        formatter = Formatter(character)

        if morgue_event.command == "!armour":
            msg = formatter.print_armour()
        elif morgue_event.command == "!weapons":
            msg = formatter.print_weapons()
        elif morgue_event.command == "!runes":
            msg = formatter.print_runes()
        elif morgue_event.command == "!spells":

            if morgue_event.level_barrier:
                msg = character.spells_above(morgue_event.level_barrier)
            else:
                msg = formatter.print_spells()

        elif morgue_event.command == "!skills":
            msg = formatter.print_skills()
        elif morgue_event.command == "!version":
            msg = formatter.print_version()
        elif morgue_event.command == "!jewellery":
            msg = formatter.print_jewellery()
            print(
                f"WE are looking for jewellery and this is what we found {msg}"
            )
        elif morgue_event.command == "!max_damage":
            msg = formatter.print_max_damage()
        elif morgue_event.command == "!mutations":
            msg = formatter.print_mutations()
        elif morgue_event.command == "!scrolls":
            msg = formatter.print_scrolls()
        elif morgue_event.command == "!potions":
            msg = formatter.print_potions()
        elif morgue_event.command == "!gods":
            msg = formatter.print_gods()
        elif morgue_event.command == "!overview":
            morgue_parser = MorgueParser(character.non_saved_morgue_file())
            msg = morgue_parser.overview()
        elif morgue_event.command == "!fetch":
            morgue_saver(character, character.non_saved_morgue_file(), True)
        elif morgue_event.command == "!fetch_s3_morgue":
            print(f"We are fetching the S3 Morgue for {character.name}")
            with open(f"tmp/s3_{character.name}.txt", "w") as f:
                f.write(character.s3_morgue_file())
        elif morgue_event.command == "!save_morgue":
            save_morgue(character)
        elif morgue_event.command == "!search":
            pass
            # for c in ["!armour", "!weapons", "!jewellery"]:
            #     call_command_with_arg(formatter, c, morgue_event.args[0])

    elif morgue_event.is_multi_character_command():
        print("A multiple Character Command!")
        if morgue_event.command == "!stalk_all":
            characters = fetch_characters()
            for character in characters:
                character = Character(name=character)
                morgue_saver(character, character.non_saved_morgue_file(),
                             True)
        elif morgue_event.command == "!rune_awards":
            rune_awards()
        elif morgue_event.command == "!characters":
            characters = fetch_characters()
            msg = ["All The Characters"] + [", ".join(characters)]
        elif morgue_event.command == "!clean_morgue":
            print("COMING SOON")
            # clean_the_morgue()
        elif morgue_event.command == "!weapon_awards":
            find_the_max_damage_for_all_characters()
    else:
        print("WE DON'T KNOW THAT COMMAND!!!!!!!")

    if morgue_event.search:
        print(f"We are searching: {morgue_event.search}")

        if type(msg) is list:
            print("Search a List")
            msg = [item for item in msg if morgue_event.search in item]
        else:
            print("Search a strang")
            if morgue_event.search not in msg:
                msg = None

    if msg:
        send_chat_to_stream(msg)
    else:
        print(
            f"No Message return for command: {morgue_event.command} character: {morgue_event.character}"
        )