Skip to content

Commit

Permalink
refactor code, platform_info func
Browse files Browse the repository at this point in the history
  • Loading branch information
aahnik committed Nov 11, 2022
1 parent ddccebb commit 94d4897
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
12 changes: 3 additions & 9 deletions tgcf/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

import typer
from dotenv import load_dotenv
from pyfiglet import Figlet
from rich import console, traceback
from rich.logging import RichHandler
from verlat import latest_release

from tgcf import __version__
from tgcf.utils import platform_info

load_dotenv(".env")

Expand Down Expand Up @@ -58,14 +58,8 @@ def verbosity_callback(value: bool):
)
topper()
logging.info("Verbosity turned on! This is suitable for debugging")
nl = "\n"
logging.info(
f"""Running tgcf {__version__}\
\nPython {sys.version.replace(nl,"")}\
\nOS {os.name}\
\nPlatform {platform.system()} {platform.release()}\
\n{platform.architecture()} {platform.processor()}"""
)

logging.info(platform_info())


def version_callback(value: bool):
Expand Down
12 changes: 12 additions & 0 deletions tgcf/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,32 @@

import logging
import os
import platform
import re
import sys
from datetime import datetime
from typing import TYPE_CHECKING

from telethon.client import TelegramClient
from telethon.hints import EntityLike
from telethon.tl.custom.message import Message

from tgcf import __version__
from tgcf.config import CONFIG

if TYPE_CHECKING:
from tgcf.plugins import TgcfMessage


def platform_info():
nl = "\n"
return f"""Running tgcf {__version__}\
\nPython {sys.version.replace(nl,"")}\
\nOS {os.name}\
\nPlatform {platform.system()} {platform.release()}\
\n{platform.architecture()} {platform.processor()}"""


async def send_message(recipient: EntityLike, tm: "TgcfMessage") -> Message:
"""Forward or send a copy, depending on config."""
client: TelegramClient = tm.message.client
Expand Down

0 comments on commit 94d4897

Please sign in to comment.