From f19fe728daac71b73af51cdd930e72b00fe29965 Mon Sep 17 00:00:00 2001 From: Paillat Date: Fri, 18 Aug 2023 10:07:52 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=80=20refactor(functionscalls.py):=20r?= =?UTF-8?q?efactor=20font=5Fmatches=20dictionary=20into=20a=20FontMatches?= =?UTF-8?q?=20class=20for=20better=20readability=20and=20maintainability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/functionscalls.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/functionscalls.py b/src/functionscalls.py index c7da912..dfb0238 100644 --- a/src/functionscalls.py +++ b/src/functionscalls.py @@ -155,15 +155,25 @@ server_normal_channel_functions = [ }, ] -font_matches = { - "standard": "ANSI Regular", - "shadow": "ANSI Shadow", - "money": random.choice( - ["Big Money-ne", "Big Money-nw", "Big Money-se", "Big Money-sw"] - ), - "bloody": "Bloody", - "dos-rebel": "DOS Rebel", -} +class FontMatches: + def __getitem__(self, key): + if key == "standard": + return "ANSI Regular" + elif key == "shadow": + return "ANSI Shadow" + elif key == "money": + return random.choice( + ["Big Money-ne", "Big Money-nw", "Big Money-se", "Big Money-sw"] + ) + elif key == "bloody": + return "Bloody" + elif key == "dos-rebel": + return "DOS Rebel" + else: + raise ValueError(f"Invalid key: {key}") + +# Example usage: +font_matches = FontMatches() unsplash_random_image_url = "https://source.unsplash.com/random"