Merge pull request #198 from Sakimori/indev

bugfixes
This commit is contained in:
Sakimori 2021-02-23 02:49:15 -05:00 committed by GitHub
commit 4247a7b33e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 14 deletions

View file

@ -374,18 +374,20 @@ def save_obl_results(winning_team, losing_team):
conn = create_connection() conn = create_connection()
if conn is not None: if conn is not None:
c=conn.cursor() c=conn.cursor()
c.execute("SELECT teams_beaten_list, current_opponent_pool, obl_points FROM one_big_league WHERE team_name = ?", (winning_team.name,))
try: try:
c.execute("SELECT teams_beaten_list, current_opponent_pool, obl_points FROM one_big_league WHERE team_name = ?", (winning_team.name,))
beaten_string, opponents_string, obl_points = c.fetchone() beaten_string, opponents_string, obl_points = c.fetchone()
except TypeError: #add team to OBL except:
add_team_obl(winning_team) return
add_team_obl(losing_team)
else:
beaten_teams = newline_string_to_list(beaten_string) beaten_teams = newline_string_to_list(beaten_string)
opponent_teams = newline_string_to_list(opponents_string) opponent_teams = newline_string_to_list(opponents_string)
if losing_team.name in opponent_teams: if re.sub('[^A-Za-z0-9 %]+', '', losing_team.name) in opponent_teams:
beaten_teams.append(losing_team.name) beaten_teams.append(losing_team.name)
opponent_teams = sample(get_filtered_teams([winning_team.name]), 5) try:
opponent_teams = sample(get_filtered_teams([re.sub('[^A-Za-z0-9 %]+', '', winning_team.name)]), 5)
except ValueError:
opponent_teams = get_filtered_teams([re.sub('[^A-Za-z0-9 %]+', '', winning_team.name)])
obl_points += 1 obl_points += 1
c.execute("UPDATE one_big_league SET teams_beaten_list = ?, current_opponent_pool = ?, obl_points = ? WHERE team_name = ?", (list_to_newline_string(beaten_teams), list_to_newline_string(opponent_teams), obl_points, winning_team.name)) c.execute("UPDATE one_big_league SET teams_beaten_list = ?, current_opponent_pool = ?, obl_points = ? WHERE team_name = ?", (list_to_newline_string(beaten_teams), list_to_newline_string(opponent_teams), obl_points, winning_team.name))

View file

@ -1306,8 +1306,12 @@ class OBLSetRivalCommand(Command):
description = "Sets your team's OBL rival. Can be changed at any time. Requires ownership." description = "Sets your team's OBL rival. Can be changed at any time. Requires ownership."
async def execute(self, msg, command): async def execute(self, msg, command):
try:
team_i = get_team_fuzzy_search(command.split("\n")[1].strip()) team_i = get_team_fuzzy_search(command.split("\n")[1].strip())
team_r = get_team_fuzzy_search(command.split("\n")[2].strip()) team_r = get_team_fuzzy_search(command.split("\n")[2].strip())
except IndexError:
await msg.channel.send("You didn't give us enough lines. Command on the top, your team in the middle, and your rival at the bottom.")
return
team, owner_id = games.get_team_and_owner(team_i.name) team, owner_id = games.get_team_and_owner(team_i.name)
if team is None or team_r is None: if team is None or team_r is None:
await msg.channel.send("Can't find one of those teams, boss. Typo?") await msg.channel.send("Can't find one of those teams, boss. Typo?")