Skip to content

Commit 4f6fa14

Browse files
committed
SRS small fix on autoupdate
Fixed player auto-unlock in competitive added terrain display in /tournament verify
1 parent fb25193 commit 4f6fa14

File tree

6 files changed

+26
-18
lines changed

6 files changed

+26
-18
lines changed

core/data/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def get_player(self, **kwargs) -> Optional[Player]:
187187
for player in self.players.values():
188188
if player.id == 1:
189189
continue
190-
if 'active' in kwargs and player.active != kwargs['active']:
190+
if kwargs.get('active') is not None and player.active != kwargs['active']:
191191
continue
192192
if 'ucid' in kwargs and player.ucid == kwargs['ucid']:
193193
return player

core/utils/discord.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ class PlayerTransformer(app_commands.Transformer):
11391139
"""
11401140
11411141
"""
1142-
def __init__(self, *, active: bool = False, watchlist: Optional[bool] = None, vip: Optional[bool] = None):
1142+
def __init__(self, *, active: Optional[bool] = None, watchlist: Optional[bool] = None, vip: Optional[bool] = None):
11431143
super().__init__()
11441144
self.active = active
11451145
self.watchlist = watchlist

extensions/srs/extension.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import ctypes
1919

2020
from configparser import RawConfigParser
21+
from contextlib import suppress
2122
from core import Extension, utils, Server, ServiceRegistry, Autoexec, get_translation, InstallException
2223
from discord.ext import tasks
2324
from services.bot import BotService
@@ -444,7 +445,7 @@ def is_installed(self) -> bool:
444445
return False
445446

446447
async def check_for_updates(self) -> Optional[str]:
447-
try:
448+
with suppress(aiohttp.ClientConnectionError):
448449
async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(
449450
ssl=ssl.create_default_context(cafile=certifi.where()))) as session:
450451
async with session.get(SRS_GITHUB_URL, proxy=self.node.proxy,
@@ -453,10 +454,7 @@ async def check_for_updates(self) -> Optional[str]:
453454
version = response.url.raw_parts[-1]
454455
if version != self.version:
455456
return version
456-
else:
457-
return None
458-
except aiohttp.ClientConnectionError:
459-
return None
457+
return None
460458

461459
def do_update(self):
462460
try:

plugins/competitive/listener.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,9 @@ def print_crew(players: list[Player]) -> str:
277277
async def remove_players(match: Match, server: Server, players: list[Player]):
278278
for player in players:
279279
match.player_dead(player)
280-
# remove the player from the running match so that they can join another one
281-
self.in_match[server.name].pop(player.ucid, None)
280+
if match.match_id != GLOBAL_MATCH_ID:
281+
# remove the player from the running match so that they can join another one
282+
self.in_match[server.name].pop(player.ucid, None)
282283
if self.get_config(server).get('kick_on_death', False):
283284
kick_time = self.get_config(server).get('kick_time', 30)
284285
self.loop.call_later(delay=kick_time,

plugins/mission/commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ async def lock(self, interaction: discord.Interaction,
10361036
@utils.app_has_role('DCS Admin')
10371037
async def unlock(self, interaction: discord.Interaction,
10381038
server: app_commands.Transform[Server, utils.ServerTransformer(status=[Status.RUNNING])],
1039-
player: app_commands.Transform[Player, utils.PlayerTransformer(active=False)]):
1039+
player: app_commands.Transform[Player, utils.PlayerTransformer()]):
10401040
if not player:
10411041
# noinspection PyUnresolvedReferences
10421042
await interaction.response.send_message(_("Player not found."), ephemeral=True)

plugins/tournament/commands.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -787,14 +787,23 @@ async def verify(self, interaction: discord.Interaction, tournament_id: int, squ
787787
await interaction.followup.send(_("Squadron ID not found."), ephemeral=True)
788788
return
789789

790-
embed = discord.Embed(color=discord.Color.blue(), title=_('Application for Squadron "{}"').format(
791-
utils.escape_string(row['name'])))
792-
embed.description = row['application']
793-
if row['image_url']:
794-
embed.set_thumbnail(url=row['image_url'])
795-
embed.add_field(name=_("# Members"), value=str(row['member_count']))
796-
embed.add_field(name=_("Role"), value=self.bot.get_role(row['role']).name if row['role'] else _("n/a"))
797-
embed.add_field(name=_("State"), value=row['status'])
790+
embed = discord.Embed(color=discord.Color.blue(), title=_('Application for Squadron "{}"').format(
791+
utils.escape_string(row['name'])))
792+
embed.description = row['application']
793+
if row['image_url']:
794+
embed.set_thumbnail(url=row['image_url'])
795+
embed.add_field(name=_("# Members"), value=str(row['member_count']))
796+
embed.add_field(name=_("Role"), value=self.bot.get_role(row['role']).name if row['role'] else _("n/a"))
797+
embed.add_field(name=_("State"), value=row['status'])
798+
799+
terrains = []
800+
async for row in await cursor.execute("""
801+
SELECT terrain FROM tm_squadron_terrain_preferences
802+
WHERE tournament_id = %s AND squadron_id = %s
803+
""", (tournament_id, squadron_id)):
804+
terrains.append('- ' + row['terrain'])
805+
if terrains:
806+
embed.add_field(name=_("Terrain Preferences"), value='\n'.join(terrains), inline=False)
798807

799808
view = ApplicationView(self, tournament_id=tournament_id, squadron_id=squadron_id)
800809
msg = await interaction.followup.send(embed=embed, view=view, ephemeral=utils.get_ephemeral(interaction))

0 commit comments

Comments
 (0)