Skip to content

Commit

Permalink
Refactor: Clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
0xuf committed Aug 15, 2022
1 parent c996250 commit cdf0025
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@


def cleanup():
"""
This function will clean the command line
"""
system("cls") if name == "nt" else system("clear")


def ascii_art():
"""
This method will print ASCII art of writeup app
"""
clear = "\x1b[0m"
colors = [36, 32, 34, 35, 31, 37]

Expand All @@ -27,14 +33,19 @@ def ascii_art():
\__/ \__|\__| \__| \____/ \_______| \______/ $$ ____/ \__| \__|$$ ____/ $$ ____/
$$ | $$ | $$ |
github.com/0xuf $$ | $$ | $$ |
\__| \__| \__|
v1.0 \__| \__| \__|
"""
for N, line in enumerate(x.split("\n")):
stdout.write("\x1b[1;%dm%s%s\n" % (choice(colors), line, clear))
sleep(0.05)


def notify_script_launch(notify_webhook) -> bool:
def notify_script_launch(notify_webhook: str) -> bool:
"""
This function will notify you when Script launched.
:param notify_webhook: get webhook_url to send message
:rtype: bool
"""
data = dict(
content=f"Writeup app launched at {datetime.now()}"
)
Expand All @@ -46,10 +57,17 @@ def notify_script_launch(notify_webhook) -> bool:


def notify_writeup(notify_webhook: str, data) -> bool:
"""
This function will notify you when it finds a new write-up on the Discord server
:param notify_webhook: get webhook_url to send message
:param data: get writeup-data to post it on discord chat
:rtype: bool
"""
author = data.get("author")
_post = data.get("post")
parse_data = f"New writeup !\n[{_post['title']}]({_post['link']})\n[{author['name']}]({author['username']}) " \
f"Wrote a writeup"
parse_data = f"🟢 New WriteUp !\n\n" \
f"🖇 WriteUp Link: ||[{_post['title']}]({_post['link']})||\n\n" \
f"🧑‍💻 Writeup Author: ||[{author['name']}]({author['username']})||\n"
data = dict(
content=parse_data
)
Expand Down

0 comments on commit cdf0025

Please sign in to comment.