Skip to content

Commit

Permalink
Fix crash if using a jade bot terminal while having a core class equi…
Browse files Browse the repository at this point in the history
…pped
  • Loading branch information
N1tR0 committed Dec 23, 2023
1 parent f1ab82f commit 444d25c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
21 changes: 16 additions & 5 deletions gw2rpc/character.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
6: "Elementalist",
7: "Mesmer",
8: "Necromancer",
9: "Revenant"
9: "Revenant",
10: "Jade Bot"
}

RACES = {0: "Asura", 1: "Charr", 2: "Human", 3: "Norn", 4: "Sylvari", 5: "Jade Bot"}
Expand Down Expand Up @@ -49,21 +50,31 @@ class Character:
def __init__(self, mumble_data, query_guild=True):
self.__mumble_data = mumble_data
self.name = mumble_data["name"]
self.race = RACES[mumble_data["race"]]
try:
self.race = RACES[mumble_data["race"]]
except KeyError:
self.race = ""
self.__api_info = None

if query_guild and api._authenticated:
self.__api_info = api.get_character(self.name)

self.profession = self.get_elite_spec()
self.profession_icon = "prof_{}".format(
self.profession.lower().replace(" ", ""))
if self.profession:
self.profession_icon = "prof_{}".format(
self.profession.lower().replace(" ", ""))
else:
self.profession = ""
self.profession_icon = "gw2rpclogo"
self.guild_tag = self._get_guild_tag()

def get_elite_spec(self):
if self.__mumble_data["spec"] not in ELITESPECS.keys():
# Meaning that its a core class, fall back
return PROFESSIONS[self.__mumble_data["profession"]]
try:
return PROFESSIONS[self.__mumble_data["profession"]]
except KeyError:
return None
else:
return ELITESPECS[self.__mumble_data["spec"]]

Expand Down
8 changes: 4 additions & 4 deletions gw2rpc/gw2rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def resource_path(relative_path):
base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
return os.path.join(base_path, relative_path)

VERSION = 2.53
VERSION = 2.54
HEADERS = {'User-Agent': 'GW2RPC v{}'.format(VERSION)}

GW2RPC_BASE_URL = "https://gw2rpc.info/api/v2/"
Expand Down Expand Up @@ -374,7 +374,7 @@ def get_region():
return ""

def get_closest_poi(map_info, continent_info):
#region = map_info.get("region_name")
##region = map_info.get("region_name")
region = map_info.get("region_id")
if config.disable_pois:
return None
Expand Down Expand Up @@ -490,7 +490,7 @@ def update_mumble_links():
if not config.hide_commander_tag and is_commander:
small_image = "commander_tag"
details = "{}: {}".format(_("Commander"), details)
elif character.race == "Jade Bot":
elif character.race == "Jade Bot" or character.profession == "Jade Bot":
small_image = "jade_bot"
else:
small_image = character.profession_icon
Expand Down Expand Up @@ -754,7 +754,7 @@ def check_for_running_rpc():
self.sdk.close()
time.sleep(self.interval)
except Exception as e:
log.critical("GW2RPC has crashed", exc_info=e)
log.critical(f"GW2RPC v{VERSION} has crashed", exc_info=e)
create_msgbox(
"GW2 Rich Presence has crashed.\nPlease check your "
"log file and report this to the author!",
Expand Down

0 comments on commit 444d25c

Please sign in to comment.