def rune_awards(logger): send_chat_to_stream(["PorscheWIN First Annual Rune Awards!!! PorscheWIN"]) for winner in _top_5_rune_holders(): send_chat_to_stream( f"{AWARD_EMOTES[winner['place']]} {PLACES[winner['place']]} Place - {winner['name']} {AWARD_EMOTES[winner['place']]} Rune Count: {len(winner['runes'])}" )
def print_the_help(logger): # Flattening List # msg = [item for sublist in nested_msg for item in sublist] commands = [item for sublist in COMMANDS.values() for item in sublist] help_msgs = [ "TheIlluminati Some Valid Commands: TheIlluminati", ", ".join(commands), ] send_chat_to_stream(help_msgs)
def weapons(name): character = Character(name=name) formatter = Formatter(character) msg = formatter.print_weapons() if msg: send_chat_to_stream(msg) return " ".join(msg) else: return "No Weapons Found!"
def armour(name): character = Character(name=name) formatter = Formatter(character) msg = formatter.print_armour() if msg: send_chat_to_stream(msg) return " ".join(msg) else: return "No Armour Found!"
def celebrate_awards(max_by_type): send_chat_to_stream(["PorscheWIN Fourth Annual Weapon Awards!!! PorscheWIN"]) for weapon_info in max_by_type: character = Character(name=weapon_info["character"]) emoji = find_emoji(weapon_info["type"]) pawn_star = PawnStar(weapon_info["weapon"]) if pawn_star.is_unrand(): unrand_emoji = "PraiseIt" else: unrand_emoji = "" send_chat_to_stream( [ f"{emoji} {unrand_emoji} Winner {weapon_info['character']} {unrand_emoji} {emoji} - Category: {weapon_info['type']}", WeaponsFormatter(character, []).format_weapon(weapon_info), ] )
def alt_rune_awards(): rune_info = _fetch_all_runes() char_runes = [char["runes"] for char in rune_info] all_runes = [item for sublist in char_runes for item in sublist] rune_counter = {} for rune in all_runes: if rune in rune_counter: rune_counter[rune] = rune_counter[rune] + 1 else: rune_counter[rune] = 1 sorted_runes = [] for rune in rune_counter: sorted_runes.append({"name": rune, "count": rune_counter[rune]}) sorted_runes = sorted(sorted_runes, key=lambda k: k["count"]) sorted_runes.reverse() send_chat_to_stream(f"BibleThump Top 5 Least Rare Runes BibleThump") for rune in sorted_runes[0:5]: print(rune) send_chat_to_stream(f"{rune['name']} - Count: {rune['count']}")
def _look_for_unrands(msg): try: new_unrands = [] # Why are we decoded as the first thing we do in a function??? decoded_msg = json.loads(msg) message = decoded_msg["Message"] print(f"\033[33mmessage: {message}\033[0m") character_weapon_info = json.loads(message) character = Character(name=character_weapon_info["character"]) new_weapons = character_weapon_info["weapons"] new_unrands = [ weapon for weapon in new_weapons if PawnStar(weapon).is_unrand() ] if new_unrands: send_chat_to_stream( f"OSFrog {character.name} got a New Unrand! OSFrog {' || '.join(new_unrands)}" ) except Exception as e: print(f"Error: {e} | msg: {msg}")
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}" )
def monitor_the_gods(event): for record in event["Records"]: msg = parse_json(record["body"]) send_chat_to_stream(msg)