mirror of
https://github.com/kaaninchen/Gleiswechsel.git
synced 2026-09-17 16:52:47 +00:00
transitous rewrite: rewrite all logs into english
This commit is contained in:
+13
-17
@@ -29,17 +29,17 @@ async def rename_vc(bot: discord.Bot, voice_channel, from_scheduler: bool = Fals
|
||||
mode = trip["mode"]
|
||||
|
||||
print("-----------------")
|
||||
logger(f"Umstieg: {long_name}; Ankunft: {arrival} Uhr")
|
||||
logger(f"Betreiber: {trip["agency"]}, Typ: {mode}")
|
||||
logger(f"Versuche Namen zu ändern, wenn nichts passiert bin ich im cooldown... (warte bis zu 10min!)")
|
||||
logger(f"Transfer: {long_name}; Arrival: {arrival}")
|
||||
logger(f"Agency: {trip["agency"]}, mode: {mode}")
|
||||
logger(f"Trying to change channel name. Discord put the bot into a cooldown if nothing happens... (automatically resolves after up to 10min)")
|
||||
|
||||
formatting = channel_formatting(mode)
|
||||
await voice_channel.edit(name=f"{formatting}{long_name}")
|
||||
await voice_channel.set_status(f"Ankunft um {arrival}")
|
||||
|
||||
logger(f"Name geändert!")
|
||||
logger(f"Updated channel name!")
|
||||
|
||||
await announcer("umstieg", voice_channel)
|
||||
await announcer("transfer", voice_channel)
|
||||
|
||||
_scheduled_task = asyncio.create_task(_schedule_next_transfer(bot, trip["arrival_dt"], voice_channel, trip["to"]))
|
||||
|
||||
@@ -51,32 +51,28 @@ async def announcer(announcement: str, voice_channel: discord.VoiceChannel, dest
|
||||
if announcements_enabled:
|
||||
if len(voice_channel.members) > 0:
|
||||
match announcement:
|
||||
case "ende":
|
||||
case "end_of_connection":
|
||||
if voice_announcement_enabled:
|
||||
announcement_status = await voice_announcer(destination, voice_channel)
|
||||
if announcement_status:
|
||||
return
|
||||
embed = build_announcement_embed(
|
||||
f'Sehr geehrte Fahrgäste,\nIn wenigen Minuten erreichen wir {destination}. Dieser Zug endet dort.\n\nWir wünschen Ihnen eine angenehme Weiterreise.\n\nVielen Dank für ihr Vertrauen und auf Wiedersehen.')
|
||||
case "umstieg":
|
||||
case "transfer":
|
||||
embed = build_info_embed()
|
||||
case _:
|
||||
logger(f"Unbekanntes Announcements: {announcement}")
|
||||
logger(f"Unknown announcement: {announcement}")
|
||||
embed = None
|
||||
|
||||
if embed:
|
||||
await voice_channel.send(embed=embed)
|
||||
|
||||
else:
|
||||
logger(f"Announcement {announcement} wird geskipped, keiner da")
|
||||
return
|
||||
|
||||
async def voice_announcer(destination: str, voice_channel: discord.VoiceChannel) -> bool:
|
||||
sound_path = get_sound_path(destination=destination)
|
||||
if sound_path is None:
|
||||
return False
|
||||
|
||||
logger(f"VC wird betreten, spiele {sound_path}")
|
||||
logger(f"Joining vc, playing {sound_path}")
|
||||
vc = await voice_channel.connect(timeout=15, reconnect=True)
|
||||
audio_source = discord.FFmpegPCMAudio(sound_path)
|
||||
|
||||
@@ -87,7 +83,7 @@ async def voice_announcer(destination: str, voice_channel: discord.VoiceChannel)
|
||||
if error:
|
||||
logger(f"Player error: {error}", "error")
|
||||
loop.create_task(vc.disconnect())
|
||||
logger("VC wird verlassen")
|
||||
logger("Leaving vc")
|
||||
|
||||
vc.play(audio_source, after=after_playing)
|
||||
return True
|
||||
@@ -100,15 +96,15 @@ async def _schedule_next_transfer(bot: discord.Bot, arrival_dt: datetime, voice_
|
||||
|
||||
if wait_seconds > 0:
|
||||
remaining = str(timedelta(seconds=wait_seconds))
|
||||
logger(f"Nächster Umstieg in {remaining.split('.')[0]} ({arrival_dt.strftime('%H:%M')} Uhr)")
|
||||
logger(f"Nexxt transfer in {remaining.split('.')[0]} ({arrival_dt.strftime('%H:%M')} Uhr)")
|
||||
|
||||
if wait_seconds > announcement_countdown:
|
||||
wait_until_end_announcement = wait_seconds - announcement_countdown
|
||||
await asyncio.sleep(wait_until_end_announcement)
|
||||
await announcer("ende", voice_channel, destination)
|
||||
await announcer("end_of_connection", voice_channel, destination)
|
||||
await asyncio.sleep(announcement_countdown)
|
||||
else:
|
||||
await asyncio.sleep(wait_seconds)
|
||||
|
||||
logger("Zug angekommen, wähle neue Verbindung")
|
||||
logger("Train arrived, searching for a new connection....")
|
||||
await rename_vc(bot, voice_channel, from_scheduler=True)
|
||||
+2
-2
@@ -6,12 +6,12 @@ def validate_channel(bot: discord.bot, server_id: int, channel_id: int):
|
||||
guild = bot.get_guild(server_id)
|
||||
|
||||
if guild is None:
|
||||
logger(f"Es konnte kein Server mit der ID {server_id} gefunden werden", "fatal")
|
||||
logger(f"Couldn't find server with ID '{server_id}', is the bot invited?", "fatal")
|
||||
return False
|
||||
|
||||
channel = guild.get_channel(channel_id)
|
||||
if not isinstance(channel, discord.VoiceChannel):
|
||||
logger(f"Es konnte kein VC mit der id {channel_id} gefunden werden", "fatal")
|
||||
logger(f"Couldn't find vc with '{channel_id}'", "fatal")
|
||||
return False
|
||||
|
||||
return channel
|
||||
|
||||
Reference in New Issue
Block a user