embed alert on player death
All checks were successful
Build and Push Docker Image / build (push) Successful in 15s

This commit is contained in:
Corban-Lee Jones 2024-12-09 14:25:11 +00:00
parent 161d44a59d
commit ac5389953f

View File

@ -38,6 +38,7 @@ class PlayersCog(commands.Cog):
@tasks.loop(seconds=3)
async def listen_for_changes(self):
log.debug("listening for changes")
for line in await self.file_handler.read():
await self.process_log_line(line)
@ -51,7 +52,8 @@ class PlayersCog(commands.Cog):
elif "disconnected player" in line:
await self.process_disconnected_player(line)
async def process_player_death(line: str):
async def process_player_death(self, line: str):
log.debug("processing player death")
re_pattern = r"\[(?P<timestamp>[\d\-:\.]+)\] user (?P<username>.+?) died at \((?P<x>\d+),(?P<y>\d+),(?P<z>\d+)\) \((?P<cause>.+?)\)"
re_match = re.search(re_pattern, line)
if not re_match:
@ -76,12 +78,22 @@ class PlayersCog(commands.Cog):
)
await player.save()
channel = self.bot.get_channel(self.bot.in_game_channel_id)
channel = channel or await self.bot.fetch_channel(self.bot.in_game_channel_id)
embed = await player.get_embed()
embed.title = "Player Has Died"
embed.colour = Colour.brand_green()
await channel.send(embed=embed)
log.debug("successfully registered player death to %s", re_match.group("username"))
async def process_connected_player(self, line: str):
"""
"""
log.debug("processing connected player")
re_pattern = r'\[(?P<timestamp>.*?)\] (?P<steam_id>\d+) "(?P<username>.*?)" fully connected \((?P<coordinates>\d+,\d+,\d+)\)'
re_match = re.search(re_pattern, line)
@ -109,6 +121,7 @@ class PlayersCog(commands.Cog):
async def process_disconnected_player(self, line: str):
"""
"""
log.debug("processing disconnected player")
re_pattern = r'\[(?P<timestamp>.*?)\] (?P<steam_id>\d+) "(?P<username>.*?)" disconnected player \((?P<coordinates>\d+,\d+,\d+)\)'
re_match = re.search(re_pattern, line)