Skip to content

Commit

Permalink
Merge pull request #2 from scottjsh/dev
Browse files Browse the repository at this point in the history
Fix table display view & Fix encoding error
  • Loading branch information
scottjsh committed May 24, 2024
2 parents f3f0965 + 4fc303f commit 02598d2
Show file tree
Hide file tree
Showing 31 changed files with 83 additions and 39 deletions.
44 changes: 29 additions & 15 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#*-* coding: utf-8 *-*
import win32gui
import pywintypes
import pywintypes # fix win32gui dll error
import asyncio
import os
import socket
Expand Down Expand Up @@ -36,6 +37,7 @@
from src.table import Table
from src.websocket import Ws
from src.os import get_os
from src.get_title import get_title

from src.account_manager.account_manager import AccountManager
from src.account_manager.account_config import AccountConfig
Expand All @@ -49,31 +51,46 @@

server = ""

# os.system("mode con cols=200 lines=50")

# import pygetwindow
# win = pygetwindow.getWindowsWithTitle(title_with_version)[0]
# win.size = (1536, 864)
try:
Logging = Logging()
log = Logging.log
except Exception as e:
print("Failed to initialize logger!")
print(e)
input("press enter to exit...\n")
os._exit(1)

# solve table display issue
os_string = get_os()
if "Windows 10" in os_string:
os.system("mode con cols=200 lines=50")
elif "Windows 11" in os_string:
try:
hwnd = win32gui.FindWindow(None, title_with_version)
x0, y0, x1, y1 = win32gui.GetWindowRect(hwnd)
win32gui.MoveWindow(hwnd, x0, y0, x0+1536, y0+864, True)
except:
print("Do not run with administrator privileges.")
input("press enter to exit...\n")
os._exit(1)
win32gui.MoveWindow(hwnd, x0, y0, x0+1286, y0+654, True)
except Exception as check_admin:
try:
hwnd = win32gui.FindWindow(None, "관리자: " + title_with_version)
x0, y0, x1, y1 = win32gui.GetWindowRect(hwnd)
win32gui.MoveWindow(hwnd, x0, y0, x0+1286, y0+654, True)
except Exception as check_korean:
try:
hwnd = win32gui.FindWindow(None, "Administrator: " + title_with_version)
x0, y0, x1, y1 = win32gui.GetWindowRect(hwnd)
win32gui.MoveWindow(hwnd, x0, y0, x0+1286, y0+654, True)
except Exception as check_english:
log(f"Failed to resize window: {check_admin}\n{check_korean}\n{check_english}\n\nAll title name: {get_title()}")
print("Do not run with administrative privilege.\nUnless please contact to scottjsh@whitesky.kr with log files.")
input("press enter to exit...\n")
os._exit(1)
else:
print("This tool only supports Windows 10, Windows 11.")
input("press enter to exit...\n")
os._exit(1)


def program_exit(status: int): # so we don't need to import the entire sys module
def program_exit(status: int):
log(f"exited program with error code {status}")
raise sys.exit(status)

Expand All @@ -93,9 +110,6 @@ def get_ip():


try:
Logging = Logging()
log = Logging.log

# OS Logging
log(f"Operating system: {get_os()}\n")

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import sys
from cx_Freeze import setup, Executable
from src.constants import version
Expand Down
1 change: 1 addition & 0 deletions src/Loadouts.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import time
import requests
from colr import color
Expand Down
1 change: 1 addition & 0 deletions src/account_manager/account_auth.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import requests
import time
import re
Expand Down
1 change: 1 addition & 0 deletions src/account_manager/account_config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import yaml
import json
import os
Expand Down
1 change: 1 addition & 0 deletions src/account_manager/account_manager.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import InquirerPy
import subprocess
import re
Expand Down
5 changes: 3 additions & 2 deletions src/chatlogs.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import glob
import os
import time
Expand All @@ -22,12 +23,12 @@ def chatLog(self, stringToLog: str):
if self.chatFileOpened:
with open(f"chat_logs/chat_log-{max(filenames)}.txt", "a") as logFile:
logFile.write(
f"{self.escape_ansi(stringToLog.encode('ascii', 'replace').decode())}\n")
f"{self.escape_ansi(stringToLog.encode('utf-8', 'replace').decode())}\n")
else:
with open(f"chat_logs/chat_log-{max(filenames) + 1}.txt", "w") as logFile:
self.chatFileOpened = True
logFile.write(
f"{self.escape_ansi(stringToLog.encode('ascii', 'replace').decode())}\n")
f"{self.escape_ansi(stringToLog.encode('utf-8', 'replace').decode())}\n")

def escape_ansi(self, line):
ansi_escape = re.compile(r'(?:\x1B[@-_]|[\x80-\x9F])[0-?]*[ -/]*[@-~]')
Expand Down
1 change: 1 addition & 0 deletions src/colors.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from colr import color
from src.constants import tierDict
import re
Expand Down
1 change: 1 addition & 0 deletions src/config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import json
from io import TextIOWrapper
from json import JSONDecodeError
Expand Down
1 change: 1 addition & 0 deletions src/configurator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import json
import os

Expand Down
3 changes: 2 additions & 1 deletion src/constants.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
import requests
from colr import color

version = "4.61"
version = "4.65"
enablePrivateLogging = True
hide_names = True
hide_levels = True
Expand Down
1 change: 1 addition & 0 deletions src/content.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import requests


Expand Down
1 change: 1 addition & 0 deletions src/errors.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import socket
import os.path
import time
Expand Down
1 change: 1 addition & 0 deletions src/experimental.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import requests


Expand Down
21 changes: 21 additions & 0 deletions src/get_title.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
import win32gui

output = []

def callback(hwnd, strings):
if win32gui.IsWindowVisible(hwnd):
window_title = win32gui.GetWindowText(hwnd)
left, top, right, bottom = win32gui.GetWindowRect(hwnd)
if window_title and right-left and bottom-top:
strings.append('0x{:08x}: "{}"'.format(hwnd, window_title))
return True

def get_title():
win_list = [] # list of strings containing win handles and window titles
win32gui.EnumWindows(callback, win_list) # populate list

for window in win_list: # print results
output.append(window)

return output
3 changes: 2 additions & 1 deletion src/logs.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import glob
import os
import time
Expand Down Expand Up @@ -34,4 +35,4 @@ def log(self, log_string: str):
current_time = time.strftime(
"%Y.%m.%d-%H.%M.%S", time.localtime(time.time()))
log_file.write(
f"[{current_time}] {log_string.encode('ascii', 'replace').decode()}\n")
f"[{current_time}] {log_string.encode('utf-8', 'replace').decode()}\n")
1 change: 1 addition & 0 deletions src/names.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import requests


Expand Down
4 changes: 1 addition & 3 deletions src/os.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# -*- coding: utf-8 -*-
import platform
import sys

# This function detects the OS the user is running and if Valorant is officially supported in said platform
# returns ["operating system" (string), "Runs Valorant" (bool)]


def get_os():
# Handles Windows operating systems
Expand Down
2 changes: 1 addition & 1 deletion src/player_stats.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

# -*- coding: utf-8 -*-
class PlayerStats:
def __init__(self, Requests, log, config):
self.Requests = Requests
Expand Down
4 changes: 1 addition & 3 deletions src/presences.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import base64
import json
import time
Expand All @@ -19,9 +20,6 @@ def get_game_state(self, presences):
def get_private_presence(self, presences):
for presence in presences:
if presence['puuid'] == self.Requests.puuid:
# preventing VAS from crashing when lol is open
# print(presence)
# print(presence.get("championId"))
if presence.get("championId") is not None or presence.get("product") == "league_of_legends":
return None
else:
Expand Down
1 change: 1 addition & 0 deletions src/questions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from InquirerPy.base.control import Choice
from src.constants import DEFAULT_CONFIG, WEAPONS

Expand Down
2 changes: 1 addition & 1 deletion src/rank.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

# -*- coding: utf-8 -*-
class Rank:
def __init__(self, Requests, log, content, ranks_before):
self.Requests = Requests
Expand Down
11 changes: 1 addition & 10 deletions src/requestsV.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import base64
import json
import time
Expand Down Expand Up @@ -50,16 +51,6 @@ def check_version(version, copy_run_update_script):
print(f"New version available! {link}")
input("press enter to exit...\n")
os._exit(1)
# if sys.argv[0][-3:] == "exe":
# while True:
# update_now = input("Do you want to update now? (Y/n): ")
# if update_now.lower() == "n" or update_now.lower() == "no":
# return
# elif update_now.lower() == "y" or update_now.lower() == "yes" or update_now == "":
# copy_run_update_script(link)
# os._exit(1)
# else:
# print('Invalid input please response with "yes" or "no" ("y", "n") or press enter to update')

@staticmethod
def copy_run_update_script(link):
Expand Down
1 change: 1 addition & 0 deletions src/rpc.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from pypresence import Presence
from pypresence.exceptions import DiscordNotFound, InvalidID
import nest_asyncio
Expand Down
1 change: 1 addition & 0 deletions src/server.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import json
import logging
from websocket_server import WebsocketServer
Expand Down
1 change: 1 addition & 0 deletions src/states/coregame.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import time


Expand Down
2 changes: 1 addition & 1 deletion src/states/menu.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

# -*- coding: utf-8 -*-

class Menu:
def __init__(self, Requests, log, presences):
Expand Down
2 changes: 1 addition & 1 deletion src/states/pregame.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

# -*- coding: utf-8 -*-

class Pregame:
def __init__(self, Requests, log):
Expand Down
1 change: 1 addition & 0 deletions src/stats.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import os
import time
import json
Expand Down
1 change: 1 addition & 0 deletions src/table.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from typing import Literal, get_args

# from prettytable import PrettyTable
Expand Down
1 change: 1 addition & 0 deletions src/websocket.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import re
import websockets
import websockets.client
Expand Down

0 comments on commit 02598d2

Please sign in to comment.