TheHamkerCat 5 rokov pred
rodič
commit
51e45d28ef
2 zmenil súbory, kde vykonal 27 pridanie a 8 odobranie
  1. 26 6
      wbb/core/sections.py
  2. 1 2
      wbb/utils/inlinefuncs.py

+ 26 - 6
wbb/core/sections.py

@@ -1,10 +1,30 @@
+n = "\n"
+w = " "
+
+
+bold = lambda x: f"**{x}:** "
+bold_ul = lambda x: f"**--{x}:**-- "
+
+mono = lambda x: f"`{x}`{n}"
+
+
 def section(
-    title: str, body: dict, indent: int = 2, underline: bool = True
+    title: str,
+    body: dict,
+    indent: int = 2,
+    underline: bool = True,
 ) -> str:
-    text = f"**--{title}**--:\n" if underline else f"**{title}**:\n"
+
+    text = (bold_ul(title) + n) if underline else bold(title) + n
+
     for key, value in body.items():
-        if not isinstance(value, list):
-            text += f"{' ' * indent}**{key.capitalize()}:** `{value}`\n"
-        else:
-            text += f"{' ' * indent}**{key.capitalize()}:** {value[0]}\n"
+        text += (
+            indent * w
+            + bold(key)
+            + (
+                (value[0] + n)
+                if isinstance(value, list)
+                else mono(value)
+            )
+        )
     return text

+ 1 - 2
wbb/utils/inlinefuncs.py

@@ -42,8 +42,7 @@ from pyrogram.types import (InlineKeyboardButton,
 from search_engine_parser import GoogleSearch
 
 from wbb import (BOT_USERNAME, MESSAGE_DUMP_CHAT, SUDOERS, USERBOT_ID,
-                 USERBOT_NAME, USERBOT_USERNAME, app,
-                 app2, arq)
+                 USERBOT_NAME, USERBOT_USERNAME, app, app2, arq)
 from wbb.core.types import InlineQueryResultCachedDocument
 from wbb.modules.info import get_chat_info, get_user_info
 from wbb.modules.music import download_youtube_audio