mirror of
https://github.com/kaaninchen/Gleiswechsel.git
synced 2026-07-21 19:52:47 +00:00
Code cleanup
This commit is contained in:
+15
-19
@@ -1,7 +1,7 @@
|
||||
import random
|
||||
import discord
|
||||
from datetime import datetime
|
||||
import src.state as state
|
||||
import handlers as handlers
|
||||
from src.utils import operator_infos, format_via_list
|
||||
|
||||
def format_timestamp(timestr):
|
||||
@@ -15,32 +15,28 @@ def format_timestamp(timestr):
|
||||
return discord.utils.format_dt(final_datetime, style="t")
|
||||
|
||||
def build_info_embed() -> discord.Embed | None:
|
||||
if state.name is None:
|
||||
if handlers.current is None:
|
||||
return None
|
||||
|
||||
operator = operator_infos(state.train)
|
||||
|
||||
if len(state.via) == 0:
|
||||
embed = discord.Embed(
|
||||
title=state.name,
|
||||
description=f"Abfahrt von {state.station} um {format_timestamp(state.departure)}",
|
||||
color=operator["color"]
|
||||
)
|
||||
else:
|
||||
embed = discord.Embed(
|
||||
title=state.name,
|
||||
description=f"Abfahrt **{format_timestamp(state.departure)}** von **{state.station}**",
|
||||
color=operator["color"]
|
||||
)
|
||||
embed.add_field(name="Über", value=format_via_list(state.via), inline=False)
|
||||
conn = handlers.current
|
||||
operator = operator_infos(conn["train"])
|
||||
name = f"{conn['train']} nach {conn['destination']}"
|
||||
embed = discord.Embed(
|
||||
title=name,
|
||||
description=f"Abfahrt von {conn['station']} um {format_timestamp(conn['departure'])}",
|
||||
color=operator["color"]
|
||||
)
|
||||
|
||||
if len(conn['via']) > 0:
|
||||
embed.add_field(name="Über", value=format_via_list(conn['via']), inline=False)
|
||||
|
||||
embed.set_author(name=operator["name"])
|
||||
embed.set_thumbnail(url=operator["logo"])
|
||||
|
||||
route_lines = []
|
||||
for stop in state.route:
|
||||
for stop in conn['route']:
|
||||
stop_name = stop["name"]
|
||||
if stop_name == state.station:
|
||||
if stop_name == conn['station']:
|
||||
route_lines.append(f"• **{stop_name}**")
|
||||
else:
|
||||
route_lines.append(f"• {stop_name}")
|
||||
|
||||
Reference in New Issue
Block a user