Skip to content

Commit de87497

Browse files
Challe-Pmosbth
authored andcommitted
Fixes nameday formatting
Also adds support for three name nameday
1 parent 861fd66 commit de87497

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

marvin_actions.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,15 +453,24 @@ def marvinNameday(row):
453453
r = requests.get(url, timeout=5)
454454
nameday_data = r.json()
455455
names = nameday_data["dagar"][0]["namnsdag"]
456+
parsed_names = formatNames(names)
456457
if names:
457-
msg = getString("nameday", "somebody").format(",".join(names))
458+
msg = getString("nameday", "somebody").format(parsed_names)
458459
else:
459460
msg = getString("nameday", "nobody")
460461
except Exception as e:
461462
LOG.error("Failed to get nameday: %s", e)
462463
msg = getString("nameday", "error")
463464
return msg
464465

466+
def formatNames(names):
467+
"""
468+
Parses namedata from nameday API
469+
"""
470+
if len(names) > 1:
471+
return " och ".join([", ".join(names[:-1])] + names[-1:])
472+
return "".join(names)
473+
465474
def marvinUptime(row):
466475
"""
467476
Display info about uptime tournament

0 commit comments

Comments
 (0)