Skip to content

Commit

Permalink
3.0.1
Browse files Browse the repository at this point in the history
dank.tool:
- replaced win10toast with win11toast
- updated notification ^
- python 3.11.3 -> 3.11.4
- dankware 3.4 -> 3.4.1
- KeyboardInterrupt error handling (executor.py)
- added dev branch
- fixed and improved run counters!


Former-commit-id: d0440a6
  • Loading branch information
SirDank committed Aug 5, 2023
1 parent 42b0b21 commit 53574d5
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 39 deletions.
10 changes: 7 additions & 3 deletions __src__/dank.tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
import time
import requests
from rich.panel import Panel
from win11toast import notify
from datetime import datetime
from rich.columns import Columns
from rich.console import Console
from win10toast import ToastNotifier
from dateutil.tz import tzlocal, tzutc
from concurrent.futures import ThreadPoolExecutor
from dankware import white, white_normal, green, red, red_normal, red_dim
from dankware import align, cls, clr, title, get_duration, multithread, err, rm_line

Expand Down Expand Up @@ -151,8 +152,11 @@ def download_offline_scripts(project):

# main

toast = ToastNotifier()
toast.show_toast("SirDank:", "Thank you for using my tool ❤️\nShare it with your friends!", duration = 10, icon_path = f"{os.path.dirname(__file__)}\\dankware.ico", threaded = True)
executor = ThreadPoolExecutor(10)
executor.submit(notify, '[ SirDank ]',
'Thank you for using my tool ❤️\nShare it with your friends!',
icon = {'src': f'{os.path.dirname(__file__)}\\dankware.ico', 'placement': 'appLogoOverride'} if os.path.exists(f'{os.path.dirname(__file__)}\\dankware.ico') else None,
image = f'{os.path.dirname(__file__)}\\red.png' if os.path.exists('red.png') else None)

while True:

Expand Down
95 changes: 63 additions & 32 deletions __src__/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
[NOTE]
- executor.py is meant to be executed only as an executable, not as a python script!
- the below imports are not required by executor.py but is required by the __modules__ run by dank.tool.py
- they are here to be imported by the installable / portable executable
- the below packages are not required by the executor.py script but is required by the various __modules__ run by the dank.tool.exe
- they are listed here to be included in the final build of dank.tool.exe
'''

import os
Expand All @@ -23,25 +23,25 @@
import pyminizip
import subprocess
import tkinter as tk
from win11toast import notify
from psutil import process_iter
from playsound import playsound
from mcstatus import JavaServer
from win10toast import ToastNotifier
from gzip import compress, decompress
from dateutil.tz import tzlocal, tzutc
from pynput.keyboard import Key, Listener
from pynput.mouse import Button, Controller
from dankware import cls, err, multithread, align, github_downloads, github_file_selector, rm_line, random_ip, get_duration, sys_open, is_admin, export_registry_keys, file_selector, folder_selector, get_path
from dankware import reset, black, blue, cyan, green, magenta, red, white, yellow, black_normal, blue_normal, cyan_normal, green_normal, magenta_normal, red_normal, white_normal, yellow_normal, black_dim, blue_dim, cyan_dim, green_dim, magenta_dim, red_dim, white_dim, yellow_dim

# required imports for dank.fusion-fall.py
# required packages for dank.fusion-fall.py

from unitypackff.asset import Asset
from unitypackff.export import OBJMesh
from unitypackff.object import FFOrderedDict, ObjectPointer
from unitypackff.modding import import_texture, import_mesh, import_audio

# required imports for executor.py
# required packages for executor.py

import requests
from pypresence import Presence
Expand All @@ -51,7 +51,7 @@

# variables

DANK_TOOL_VERSION = "3.0"
DANK_TOOL_VERSION = "3.0.1"
session = requests.Session()
executor = ThreadPoolExecutor(10)
headers = {"User-Agent": "dank.tool"}
Expand All @@ -61,19 +61,31 @@
title("𝚍𝚊𝚗𝚔.𝚝𝚘𝚘𝚕 [ 𝚒𝚗𝚒𝚝𝚒𝚊𝚕𝚒𝚣𝚒𝚗𝚐 ]")
print(clr(f"\n > Version: {DANK_TOOL_VERSION}"))

# rediect stderr to a file
#if not os.path.exists('__logs__'): os.mkdir('__logs__')
#sys.stderr = open('__logs__/dank.tool.log', 'w', encoding='utf-8')

# debug env variables

os.environ['DANK_TOOL_OFFLINE_DEV'] = ("1" if os.path.isfile('debug') else "0")
os.environ['DANK_TOOL_ONLINE_DEV'] = ("1" if os.path.isfile('debug-online') else "0")
ONLINE_DEV = int(os.environ['DANK_TOOL_ONLINE_DEV'])
OFFLINE_DEV = int(os.environ['DANK_TOOL_OFFLINE_DEV'])
branch = ("main" if not ONLINE_DEV else "dev")

# handle KeyboardInterrupt

def print_warning_symbol():

warning_symbol = f'\n\n{red} ██ \n{red} ██ ██ \n{red} ██ ██ \n{red} ██ ██ \n{red} ██ ██ \n{red} ██ ██ \n{red} ██ {white}██████{red} ██ \n{red} ██ {white}██████{red} ██ \n{red} ██ {white}██████{red} ██ \n{red} ██ {white}██████{red} ██ \n{red} ██ {white}██████{red} ██ \n{red} ██ {white}██████{red} ██ \n{red} ██ {white}██████{red} ██ \n{red} ██ {white}██████{red} ██ \n{red} ██ ██ \n{red} ██ {white}██████{red} ██ \n{red} ██ {white}██████{red} ██ \n{red}██ {white}██████{red} ██\n{red}██ ██\n{red} ██████████████████████████████████████████ \n'
cls(); print(align(warning_symbol))

# get latest version number

def latest_dank_tool_version():

try:
LATEST_VERSION = session.get(f"https://raw.githubusercontent.com/SirDank/dank.tool/main/__src__/executor_version{'' if not ONLINE_DEV else '_dev'}.txt", headers=headers).content.decode()
LATEST_VERSION = session.get(f"https://raw.githubusercontent.com/SirDank/dank.tool/{branch}/__src__/executor_version.txt", headers=headers).content.decode()
os.environ['DANK_TOOL_ONLINE'] = "1"
except:
LATEST_VERSION = "0"
Expand All @@ -84,21 +96,22 @@ def latest_dank_tool_version():
LATEST_VERSION = latest_dank_tool_version()
ONLINE_MODE = int(os.environ['DANK_TOOL_ONLINE'])
ONLINE_DEV = int(os.environ['DANK_TOOL_ONLINE_DEV'])
branch = ("main" if not ONLINE_DEV else "dev")

# version checker / updater

def dank_tool_installer():

while True:
try:
code = session.get(f"https://raw.githubusercontent.com/SirDank/dank.tool/main/__src__/updater{'' if not ONLINE_DEV else '_dev'}.py", headers=headers).content.decode()
code = session.get(f"https://raw.githubusercontent.com/SirDank/dank.tool/{branch}/__src__/updater.py", headers=headers).content.decode()
break
except: input(clr("\n > Failed to get code! Make sure you are connected to the internet! Press [ENTER] to try again... ",2))

try: exec(code)
except:
err_message = err(sys.exc_info())
try: session.post("https://dank-site.onrender.com/dank-tool-errors", headers=headers, data={"text": f"```<--- 🚨 ---> Version: {DANK_TOOL_VERSION}\n\n{err_message}```"})
try: session.post("https://dank-site.onrender.com/dank-tool-errors", headers=headers, data={"text": f"```<--- 🚨🚨🚨 ---> Version: {DANK_TOOL_VERSION}\n\n{err_message}```"})
except: pass
input(clr(f"{err_message}\n\n > Press [ENTER] to EXIT... ",2))
sys.exit(err_message)
Expand All @@ -110,26 +123,30 @@ def dank_tool_installer():
if parse(LATEST_VERSION) > parse(DANK_TOOL_VERSION) or os.path.isfile('force-update'):
print(clr(f"\n > Update Found: {LATEST_VERSION}" + ("" if not os.path.isfile('force-update') else " [ FORCED ]")))
dank_tool_installer()

elif LATEST_VERSION == DANK_TOOL_VERSION:
if not ONLINE_DEV:
print(clr(f"\n > Latest Version!"))
else:
print(clr(f"\n > Online Development Mode!"))

elif LATEST_VERSION == "0":
print(clr("\n > Offline Mode!"))

else: # LATEST VERSION IS LESS THAN CURRENT VERSION
print(clr("\n > Development Mode!"))
os.environ['DANK_TOOL_OFFLINE_DEV'] = "1"
OFFLINE_DEV = 1
print(clr("\n > Development Version!"))
#os.environ['DANK_TOOL_OFFLINE_DEV'] = "1"
#OFFLINE_DEV = 1

# get and save dank.tool.py

if not os.path.exists('__src__'): os.mkdir('__src__')
if not os.path.exists('__modules__'): os.mkdir('__modules__')
if not os.path.exists('__local_modules__'): os.mkdir('__local_modules__')

if not OFFLINE_DEV and ( ONLINE_MODE or not os.path.exists('__src__/dank.tool.py') ):
while True:
try: code = session.get(f"https://raw.githubusercontent.com/SirDank/dank.tool/main/__src__/dank.tool{'' if not ONLINE_DEV else '_dev'}.py", headers=headers).content.decode(); break
try: code = session.get(f"https://raw.githubusercontent.com/SirDank/dank.tool/{branch}/__src__/dank.tool.py", headers=headers).content.decode(); break
except: input(clr("\n > Failed to get code! Make sure you are connected to the internet! Press [ENTER] to try again... ",2))
open('__src__/dank.tool.py', 'w', encoding='utf-8').write(code)
else:
Expand Down Expand Up @@ -157,30 +174,37 @@ def dank_tool_discord_rpc():

if ONLINE_MODE:
try:
os.environ['DISCORD_RPC'] = "on the main menu"
RPC = Presence("1028269752386326538")
RPC.connect(); os.environ['DISCORD_RPC'] = "on the main menu"
RPC.connect()
executor.submit(dank_tool_discord_rpc)
except: pass

# update counter

def dank_tool_runs_counter():

fail_counter = 0
session = requests.Session()
while True:
try: session.get("https://api.countapi.xyz/hit/dank.tool2", headers=headers); break
except: pass
time.sleep(240)
if fail_counter > 3: break
try: session.get("https://dank-site.onrender.com/counter?id=dank.tool&hit=true", headers=headers); break
except: fail_counter += 1
time.sleep(60)

if ONLINE_MODE:
executor.submit(dank_tool_runs_counter)

# chatroom user validator

def dank_tool_chatroom():

fail_counter = 0
session = requests.Session()
while True:
try: session.post("https://dank-site.onrender.com/chatroom-users", headers=headers)
except: pass
if fail_counter > 2: break
try: session.post("https://dank-site.onrender.com/chatroom-users", headers=headers); fail_counter = 0 # do not add a break here! (keeps user validated)
except: fail_counter += 1
time.sleep(240)

if ONLINE_MODE:
Expand All @@ -190,26 +214,33 @@ def dank_tool_chatroom():

title(f"𝚍𝚊𝚗𝚔.𝚝𝚘𝚘𝚕 {DANK_TOOL_VERSION}")

if not ONLINE_MODE:
time.sleep(5)

try: exec(code)
except:

cls()
err_message = err(sys.exc_info())
print(clr(err_message, 2))
LATEST_VERSION = latest_dank_tool_version()
if parse(LATEST_VERSION) > parse(DANK_TOOL_VERSION):

if "Error Type: KeyboardInterrupt" in err_message:
print_warning_symbol()
print(clr("\n > Please do not use [ CTRL + C ] when running the dank.tool!"))

elif parse(LATEST_VERSION) > parse(DANK_TOOL_VERSION):
print(clr(f"\n > Updating to the latest version...\n\n > Update Found: {LATEST_VERSION}"))
dank_tool_installer()
else:
if ONLINE_MODE:
#user_message = input(clr("\n > Briefly explain what you were doing when this error occurred [ sent to the developer ]: ",2) + white)
while True:
try:
#if user_message == "": content = f"```<--- 🚨 ---> Version: {DANK_TOOL_VERSION}\n\n{err_message}```"
#else: content = f"```<--- 🚨 ---> Version: {DANK_TOOL_VERSION}\n\n{err_message}\n\n > Message: {user_message}```"
session.post("https://dank-site.onrender.com/dank-tool-errors", headers=headers, data={"text": f"```<--- 🚨 ---> Version: {DANK_TOOL_VERSION}\n\n{err_message}```"})
break
except: input(clr(f"\n > Failed to post error report! Make sure you are connected to the internet! Press [ENTER] to try again... ",2))
print(clr("\n > Error Reported! If it is an OS error, Please run as admin and try again!\n\n > If it is a logic error, it will be fixed soon!"))
input(clr("\n > Press [ENTER] to EXIT... "))

elif ONLINE_MODE:
while True:
try:
session.post("https://dank-site.onrender.com/dank-tool-errors", headers=headers, data={"text": f"```<--- 🚨🚨🚨 ---> Version: {DANK_TOOL_VERSION}\n\n{err_message}```"})
break
except: input(clr(f"\n > Failed to post error report! Make sure you are connected to the internet! Press [ENTER] to try again... ",2))
print(clr("\n > Error Reported! If it is an OS error, Please run as admin and try again!\n\n > If it is a logic error, it will be fixed soon!"))

input(clr("\n > Press [ENTER] to EXIT... "))
os.system("taskkill /f /im dank.tool.exe")

2 changes: 1 addition & 1 deletion __src__/executor_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0
3.0.1
2 changes: 1 addition & 1 deletion dank.tool.exe.REMOVED.git-id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9651688eb454278436a5dda41ededc8f001e0466
f8ce10c5b43e1d73eeb5f43c45e6565584876ea7
2 changes: 1 addition & 1 deletion dank.tool.zip.REMOVED.git-id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a423d36f086d9d111293bc966f2043ba3dd4e5ca
347029d3b3f91ca10570f4241524219735b84e2a
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ python-dateutil
requests
rich
unitypackff
win10toast
win11toast

0 comments on commit 53574d5

Please sign in to comment.