mirror of
https://github.com/fishyboteso/fishyboteso.git
synced 2024-08-30 18:32:13 +00:00
0.3.0 bugs squashed
- sends hole_deplete even on interupt - application doesnt restart after updating - image doesnt display in shortcut - optimize startup: multithreaded web request for gui init
This commit is contained in:
parent
3fdfb35622
commit
79c7f748e1
Binary file not shown.
@ -1,6 +1,9 @@
|
|||||||
|
import ctypes
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
from os import execl
|
||||||
from tkinter import messagebox
|
from tkinter import messagebox
|
||||||
|
|
||||||
import win32con
|
import win32con
|
||||||
@ -129,6 +132,14 @@ def initialize(gui, c: Config):
|
|||||||
logging.error("Couldn't create a session, some features might not work")
|
logging.error("Couldn't create a session, some features might not work")
|
||||||
print(f"created session {new_session}")
|
print(f"created session {new_session}")
|
||||||
|
|
||||||
|
try:
|
||||||
|
is_admin = os.getuid() == 0
|
||||||
|
except AttributeError:
|
||||||
|
is_admin = ctypes.windll.shell32.IsUserAnAdmin() != 0
|
||||||
|
|
||||||
|
if is_admin and c.get("debug"):
|
||||||
|
logging.info("Running with admin privileges")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
auto_upgrade()
|
auto_upgrade()
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -37,6 +37,7 @@ class GUIFunction(Enum):
|
|||||||
STARTED = 1 # args: bool
|
STARTED = 1 # args: bool
|
||||||
ASK_DIRECTORY = 2 # callback: callable
|
ASK_DIRECTORY = 2 # callback: callable
|
||||||
SHOW_ERROR = 3
|
SHOW_ERROR = 3
|
||||||
|
SET_NOTIFY = 4
|
||||||
|
|
||||||
|
|
||||||
class GUI:
|
class GUI:
|
||||||
@ -54,7 +55,8 @@ class GUI:
|
|||||||
self.root = None
|
self.root = None
|
||||||
self.console = None
|
self.console = None
|
||||||
self.start_button = None
|
self.start_button = None
|
||||||
self.notif = None
|
self.notify = None
|
||||||
|
self.notify_check = None
|
||||||
|
|
||||||
self.thread = threading.Thread(target=self.create, args=())
|
self.thread = threading.Thread(target=self.create, args=())
|
||||||
|
|
||||||
@ -99,8 +101,8 @@ class GUI:
|
|||||||
logging.debug("Restart to update the changes")
|
logging.debug("Restart to update the changes")
|
||||||
|
|
||||||
debug_menu.add_checkbutton(label="Keep Console", command=keep_console, variable=debug_var)
|
debug_menu.add_checkbutton(label="Keep Console", command=keep_console, variable=debug_var)
|
||||||
|
|
||||||
debug_menu.add_command(label="Log Dump", command=lambda: logging.error("Not Implemented"))
|
debug_menu.add_command(label="Log Dump", command=lambda: logging.error("Not Implemented"))
|
||||||
|
debug_menu.add_command(label="Restart", command=helper.restart)
|
||||||
menubar.add_cascade(label="Debug", menu=debug_menu)
|
menubar.add_cascade(label="Debug", menu=debug_menu)
|
||||||
|
|
||||||
help_menu = Menu(menubar, tearoff=0)
|
help_menu = Menu(menubar, tearoff=0)
|
||||||
@ -126,9 +128,17 @@ class GUI:
|
|||||||
|
|
||||||
Label(left_frame, text="Notification:").grid(row=0, column=0)
|
Label(left_frame, text="Notification:").grid(row=0, column=0)
|
||||||
|
|
||||||
self.notif = IntVar(value=int(web.is_subbed(self.config.get('uid'))))
|
self.notify = IntVar(0)
|
||||||
Checkbutton(left_frame, command=self.give_notification_link,
|
self.notify_check = Checkbutton(left_frame, command=self.give_notification_link,
|
||||||
variable=self.notif).grid(row=0, column=1)
|
variable=self.notify)
|
||||||
|
self.notify_check.grid(row=0, column=1)
|
||||||
|
self.notify_check['state'] = DISABLED
|
||||||
|
|
||||||
|
def update_notify_check():
|
||||||
|
is_subbed = web.is_subbed(self.config.get('uid'))
|
||||||
|
self.call(GUIFunction.SET_NOTIFY, (int(is_subbed[0]),is_subbed[1]))
|
||||||
|
|
||||||
|
threading.Thread(target=update_notify_check).start()
|
||||||
|
|
||||||
Label(left_frame, text="Fullscreen: ").grid(row=1, column=0, pady=(5, 5))
|
Label(left_frame, text="Fullscreen: ").grid(row=1, column=0, pady=(5, 5))
|
||||||
borderless = Checkbutton(left_frame, )
|
borderless = Checkbutton(left_frame, )
|
||||||
@ -199,6 +209,10 @@ class GUI:
|
|||||||
threading.Thread(target=func[1][0], args=(path,)).start()
|
threading.Thread(target=func[1][0], args=(path,)).start()
|
||||||
elif func[0] == GUIFunction.SHOW_ERROR:
|
elif func[0] == GUIFunction.SHOW_ERROR:
|
||||||
messagebox.showerror("ERROR", func[1][0])
|
messagebox.showerror("ERROR", func[1][0])
|
||||||
|
elif func[0] == GUIFunction.SET_NOTIFY:
|
||||||
|
self.notify.set(func[1][0])
|
||||||
|
if func[1][1]:
|
||||||
|
self.notify_check['state'] = NORMAL
|
||||||
|
|
||||||
def _apply_theme(self, dark):
|
def _apply_theme(self, dark):
|
||||||
self.root["theme"] = "equilux" if dark else "breeze"
|
self.root["theme"] = "equilux" if dark else "breeze"
|
||||||
@ -238,22 +252,22 @@ class GUI:
|
|||||||
def give_notification_link(self):
|
def give_notification_link(self):
|
||||||
from fishy.systems import web
|
from fishy.systems import web
|
||||||
|
|
||||||
if web.is_subbed(self.config.get("uid")):
|
if web.is_subbed(self.config.get("uid"))[0]:
|
||||||
web.unsub(self.config.get("uid"))
|
web.unsub(self.config.get("uid"))
|
||||||
return
|
return
|
||||||
|
|
||||||
# set notification checkbutton
|
# set notification checkbutton
|
||||||
self.notif.set(0)
|
self.notify.set(0)
|
||||||
|
|
||||||
def quit_top():
|
def quit_top():
|
||||||
top.destroy()
|
top.destroy()
|
||||||
top_running[0] = False
|
top_running[0] = False
|
||||||
|
|
||||||
def check():
|
def check():
|
||||||
if web.is_subbed(self.config.get("uid"), False):
|
if web.is_subbed(self.config.get("uid"), False)[0]:
|
||||||
messagebox.showinfo("Note!", "Notification configured successfully!")
|
messagebox.showinfo("Note!", "Notification configured successfully!")
|
||||||
web.send_notification(self.config.get("uid"), "Sending a test notification :D")
|
web.send_notification(self.config.get("uid"), "Sending a test notification :D")
|
||||||
self.notif.set(1)
|
self.notify.set(1)
|
||||||
quit_top()
|
quit_top()
|
||||||
else:
|
else:
|
||||||
messagebox.showerror("Error", "Subscription wasn't successful")
|
messagebox.showerror("Error", "Subscription wasn't successful")
|
||||||
|
@ -14,7 +14,10 @@ import numpy as np
|
|||||||
from uuid import uuid1
|
from uuid import uuid1
|
||||||
from hashlib import md5
|
from hashlib import md5
|
||||||
|
|
||||||
|
from win32com.client import Dispatch
|
||||||
|
|
||||||
import fishy
|
import fishy
|
||||||
|
import winshell
|
||||||
import functools
|
import functools
|
||||||
|
|
||||||
from fishy.systems.gui import GUIFunction
|
from fishy.systems.gui import GUIFunction
|
||||||
@ -60,9 +63,6 @@ def open_web(website):
|
|||||||
Thread(target=lambda: webbrowser.open(website, new=2)).start()
|
Thread(target=lambda: webbrowser.open(website, new=2)).start()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def create_new_uid():
|
def create_new_uid():
|
||||||
return md5(str(uuid1()).encode()).hexdigest()
|
return md5(str(uuid1()).encode()).hexdigest()
|
||||||
|
|
||||||
@ -114,7 +114,16 @@ def create_shortcut(gui):
|
|||||||
|
|
||||||
|
|
||||||
def _copy_shortcut(path):
|
def _copy_shortcut(path):
|
||||||
shutil.copy(get_data_file_path('FishybotESO.lnk'), path)
|
desktop = winshell.desktop()
|
||||||
|
path = os.path.join(desktop, "Fishybot ESO.lnk")
|
||||||
|
|
||||||
|
shell = Dispatch('WScript.Shell')
|
||||||
|
shortcut = shell.CreateShortCut(path)
|
||||||
|
shortcut.Targetpath = os.path.join(os.path.dirname(sys.executable), "python.exe")
|
||||||
|
shortcut.Arguments = "-m fishy"
|
||||||
|
shortcut.IconLocation = get_data_file_path("icon.ico")
|
||||||
|
shortcut.save()
|
||||||
|
|
||||||
logging.info("Shortcut created")
|
logging.info("Shortcut created")
|
||||||
|
|
||||||
|
|
||||||
@ -130,3 +139,7 @@ def check_addon():
|
|||||||
"Also, make sure the addon is visible clearly on top left corner of the game window")
|
"Also, make sure the addon is visible clearly on top left corner of the game window")
|
||||||
except Exception:
|
except Exception:
|
||||||
print("couldn't install addon, try doing it manually")
|
print("couldn't install addon, try doing it manually")
|
||||||
|
|
||||||
|
|
||||||
|
def restart():
|
||||||
|
os.execl(sys.executable, *([sys.executable] + sys.argv))
|
||||||
|
@ -83,18 +83,18 @@ def send_hole_deplete(uid, fish_caught, hole_time, fish_times):
|
|||||||
requests.post(domain + hole_depleted, json=body)
|
requests.post(domain + hole_depleted, json=body)
|
||||||
|
|
||||||
|
|
||||||
@fallback(False)
|
@fallback((False, False))
|
||||||
def is_subbed(uid, lazy=True):
|
def is_subbed(uid, lazy=True):
|
||||||
if lazy and G._is_subbed is not None:
|
if lazy and G._is_subbed is not None:
|
||||||
return G._is_subbed
|
return G._is_subbed, True
|
||||||
|
|
||||||
if uid is None:
|
if uid is None:
|
||||||
return False
|
return False, False
|
||||||
|
|
||||||
body = {"uid": uid}
|
body = {"uid": uid}
|
||||||
response = requests.get(domain + subscription, params=body)
|
response = requests.get(domain + subscription, params=body)
|
||||||
G._is_subbed = response.json()["subbed"]
|
G._is_subbed = response.json()["subbed"]
|
||||||
return G._is_subbed
|
return G._is_subbed, True
|
||||||
|
|
||||||
|
|
||||||
@fallback(None)
|
@fallback(None)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
winshell
|
||||||
imutils
|
imutils
|
||||||
numpy
|
numpy
|
||||||
opencv_python
|
opencv_python
|
||||||
|
Loading…
Reference in New Issue
Block a user