diff --git a/balance.py b/balance.py index 3da4de5..fb5372c 100644 --- a/balance.py +++ b/balance.py @@ -149,6 +149,8 @@ def fetch_ratings(self, players, request_id): p[gt]["time"] = t p[gt]["local"] = False self.ratings[sid][gt] = p[gt] + if self.ratings[sid][gt]["elo"] == 0 and self.ratings[sid][gt]["games"] == 0: + self.ratings[sid][gt]["elo"] = DEFAULT_RATING if sid in players and gt == players[sid]: # The API gave us the game type we wanted, so we remove it. @@ -156,7 +158,7 @@ def fetch_ratings(self, players, request_id): # Fill the rest of the game types the API didn't return but supports. for gt in SUPPORTED_GAMETYPES: - if gt not in self.ratings[sid] or (gt in self.ratings[sid] and self.ratings[sid][gt] == 0): + if gt not in self.ratings[sid]: self.ratings[sid][gt] = {"games": -1, "elo": DEFAULT_RATING, "local": False, "time": time.time()} # If the API didn't return all the players, we set them to the default rating. @@ -431,7 +433,7 @@ def callback_teams(self, players, channel): minimum_suggestion_diff = self.get_cvar("qlx_balanceMinimumSuggestionDiff", int) if switch and switch[1] >= minimum_suggestion_diff: - channel.reply("SUGGESTION: switch ^6{}^7 with ^6{}^7. Type !a to agree." + channel.reply("SUGGESTION: switch ^6{}^7 with ^6{}^7. Mentioned players can type !a to agree." .format(switch[0][0].clean_name, switch[0][1].clean_name)) if not self.suggested_pair or self.suggested_pair[0] != switch[0][0] or self.suggested_pair[1] != switch[0][1]: self.suggested_pair = (switch[0][0], switch[0][1]) diff --git a/ban.py b/ban.py index a281707..85463ba 100644 --- a/ban.py +++ b/ban.py @@ -311,7 +311,11 @@ def cmd_forgive(self, player, msg, channel): channel.reply("I do not know ^6{}^7.".format(name)) return - leaves = int(self.db[base_key + ":games_left"]) + try: + leaves = int(self.db[base_key + ":games_left"]) + except KeyError: + leaves = 0 + if leaves <= 0: channel.reply("^6{}^7's leaves are already at ^6{}^7.".format(name, leaves)) return @@ -393,5 +397,5 @@ def leave_status(self, steam_id): return action, ratio def warn_player(self, player, ratio): - player.tell("^7You have only completed ^6{}^7 percent of your games.".format(round(ratio * 100, 1))) + player.tell("^7You have only completed ^6{}^7 percent of your games.".format(round((completed / total) * 100, 1))) player.tell("^7If you keep leaving you ^6will^7 be banned.") diff --git a/fun.py b/fun.py index d176eea..2485a00 100644 --- a/fun.py +++ b/fun.py @@ -53,6 +53,14 @@ _re_quakelive = re.compile(r"^(?:ql|quake live)\W?$", flags=re.IGNORECASE) _re_chaching = re.compile(r"(?:\$|€|£)\d+", flags=re.IGNORECASE) _re_uh_ah = re.compile(r"^uh ah$", flags=re.IGNORECASE) +_re_oohwee = re.compile(r"^ooh+wee\W?$", flags=re.IGNORECASE) +_re_erah = re.compile(r"^erah\W?$", flags=re.IGNORECASE) +_re_yeahhh = re.compile(r"^yeahhh\W?$", flags=re.IGNORECASE) +_re_scream = re.compile(r"^scream\W?$", flags=re.IGNORECASE) +_re_salute = re.compile(r"^salute\W?$", flags=re.IGNORECASE) +_re_squish = re.compile(r"^squish\W?$", flags=re.IGNORECASE) +_re_oh_god = re.compile(r"^oh god\W?$", flags=re.IGNORECASE) +_re_snarl = re.compile(r"^snarl\W?$", flags=re.IGNORECASE) class fun(minqlx.Plugin): database = Redis @@ -136,6 +144,22 @@ def handle_chat(self, player, msg, channel): self.play_sound("sound/misc/chaching") elif _re_uh_ah.match(msg): self.play_sound("sound/player/mynx/taunt.wav") + elif _re_oohwee.match(msg): + self.play_sound("sound/player/anarki/taunt.wav") + elif _re_erah.match(msg): + self.play_sound("sound/player/bitterman/taunt.wav") + elif _re_yeahhh.match(msg): + self.play_sound("sound/player/major/taunt.wav") + elif _re_scream.match(msg): + self.play_sound("sound/player/bones/taunt.wav") + elif _re_salute.match(msg): + self.play_sound("sound/player/sarge/taunt.wav") + elif _re_squish.match(msg): + self.play_sound("sound/player/orb/taunt.wav") + elif _re_oh_god.match(msg): + self.play_sound("sound/player/ranger/taunt.wav") + elif _re_snarl.match(msg): + self.play_sound("sound/player/sorlag/taunt.wav") def play_sound(self, path): if not self.last_sound: