diff --git a/MANIFEST.in b/MANIFEST.in index 9b1ebd9..1893aa9 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -5,6 +5,7 @@ include fishy/icon.ico include fishy/ProvisionsChalutier.zip include fishy/FooAddon.zip include fishy/fishybot_logo.png +include fishy/sound.mp3 recursive-include tests * recursive-exclude * __pycache__ diff --git a/fishy/__init__.py b/fishy/__init__.py index 2e6155a..24dd90e 100644 --- a/fishy/__init__.py +++ b/fishy/__init__.py @@ -1,2 +1,2 @@ from fishy.__main__ import main -__version__ = "0.3.11" +__version__ = "0.3.13" diff --git a/fishy/__main__.py b/fishy/__main__.py index d720b1d..2606584 100644 --- a/fishy/__main__.py +++ b/fishy/__main__.py @@ -3,6 +3,7 @@ import logging import os import sys import traceback +from threading import Thread import win32con import win32gui @@ -10,7 +11,7 @@ import win32gui import fishy from fishy import web, helper, gui from fishy.engine.event_handler import EngineEventHandler -from fishy.gui import GUI +from fishy.gui import GUI, splash from fishy.helper import Config, hotkey @@ -57,8 +58,12 @@ def initialize(c: Config, window_to_hide): def main(): + splash.start() print("launching please wait...") + pil_logger = logging.getLogger('PIL') + pil_logger.setLevel(logging.INFO) + window_to_hide = win32gui.GetForegroundWindow() c = Config() diff --git a/fishy/engine/semifisher/engine.py b/fishy/engine/semifisher/engine.py index 1ac80f7..775d115 100644 --- a/fishy/engine/semifisher/engine.py +++ b/fishy/engine/semifisher/engine.py @@ -46,7 +46,7 @@ class SemiFisherEngine(IEngine): FishingMode("hook", 0, HookEvent(action_key, False)) FishingMode("stick", 1, StickEvent()) FishingMode("look", 2, LookEvent(action_key)) - FishingMode("idle", 3, IdleEvent(self.config.get("uid"))) + FishingMode("idle", 3, IdleEvent(self.config.get("uid"), self.config.get("sound_notification"))) self.fishPixWindow = Window(color=cv2.COLOR_RGB2HSV) diff --git a/fishy/engine/semifisher/fishing_event.py b/fishy/engine/semifisher/fishing_event.py index 029db51..67ffb2e 100644 --- a/fishy/engine/semifisher/fishing_event.py +++ b/fishy/engine/semifisher/fishing_event.py @@ -8,8 +8,10 @@ import time from abc import abstractmethod, ABC import pyautogui +from playsound import playsound from fishy import web +from fishy.helper import helper _fishCaught = 0 _totalFishCaught = 0 @@ -85,11 +87,12 @@ class IdleEvent(FishEvent): State when the fishing hole is depleted or the bot is doing nothing """ - def __init__(self, uid): + def __init__(self, uid, sound: bool): """ sets the flag to send notification on phone """ self.uid = uid + self.sound = sound def on_enter_callback(self, previous_mode): """ @@ -101,6 +104,8 @@ class IdleEvent(FishEvent): if _fishCaught > 0: web.send_hole_deplete(self.uid, _fishCaught, time.time() - _hole_start_time, _fish_times) _fishCaught = 0 + if self.sound: + playsound(helper.manifest_file("sound.mp3"), False) if previous_mode.name == "hook": logging.info("HOLE DEPLETED") diff --git a/fishy/gui/config_top.py b/fishy/gui/config_top.py index 5628b24..fe19042 100644 --- a/fishy/gui/config_top.py +++ b/fishy/gui/config_top.py @@ -34,6 +34,7 @@ def start_semifisher_config(gui: 'GUI'): def save(): gui._config.set("action_key", action_key_entry.get(), False) gui._config.set("borderless", borderless.instate(['selected']), False) + gui._config.set("sound_notification", sound.instate(['selected']), False) gui._config.save_config() top = PopUp(save, gui._root, background=gui._root["background"]) @@ -61,5 +62,9 @@ def start_semifisher_config(gui: 'GUI'): action_key_entry.grid(row=2, column=1) action_key_entry.insert(0, gui._config.get("action_key", "e")) + Label(controls_frame, text="Sound Notification: ").grid(row=3, column=0, pady=(5, 5)) + sound = Checkbutton(controls_frame, var=BooleanVar(value=gui._config.get("sound_notification"))) + sound.grid(row=3, column=1) + controls_frame.pack(padx=(5, 5), pady=(5, 5)) top.start() diff --git a/fishy/gui/main_gui.py b/fishy/gui/main_gui.py index 6b88f05..4d86008 100644 --- a/fishy/gui/main_gui.py +++ b/fishy/gui/main_gui.py @@ -34,7 +34,8 @@ def _create(gui: 'GUI'): menubar = Menu(gui._root) filemenu = Menu(menubar, tearoff=0) - filemenu.add_command(label="Create Shortcut", command=helper.create_shortcut) + filemenu.add_command(label="Create Shortcut", command=lambda: helper.create_shortcut(False)) + filemenu.add_command(label="Create Anti-Ghost Shortcut", command=lambda: helper.create_shortcut(True)) def _toggle_mode(): gui._config.set("dark_mode", not gui._config.get("dark_mode", True)) diff --git a/fishy/gui/splash.py b/fishy/gui/splash.py new file mode 100644 index 0000000..ea7ad86 --- /dev/null +++ b/fishy/gui/splash.py @@ -0,0 +1,31 @@ +import time +from multiprocessing import Process +from tkinter import * +from PIL import Image, ImageTk + +from fishy.helper import helper + + +def show(): + top = Tk() + + # top.overrideredirect(True) + # top.lift() + + top.title("Loading...") + top.resizable(False, False) + top.iconbitmap(helper.manifest_file('icon.ico')) + + canvas = Canvas(top, width=300, height=200) + canvas.pack() + top.image = Image.open(helper.manifest_file('fishybot_logo.png')).resize((300, 200)) + top.image = ImageTk.PhotoImage(top.image) + canvas.create_image(0, 0, anchor=NW, image=top.image) + + top.update() + time.sleep(3) + top.destroy() + + +def start(): + Process(target=show).start() diff --git a/fishy/helper/helper.py b/fishy/helper/helper.py index 23d7ebd..df70fc3 100644 --- a/fishy/helper/helper.py +++ b/fishy/helper/helper.py @@ -102,7 +102,7 @@ def create_shortcut_first(c): # noinspection PyBroadException -def create_shortcut(): +def create_shortcut(anti_ghosting: bool): """ creates a new shortcut on desktop """ @@ -112,13 +112,21 @@ def create_shortcut(): shell = Dispatch('WScript.Shell') shortcut = shell.CreateShortCut(path) - shortcut.TargetPath = os.path.join(os.path.dirname(sys.executable), "python.exe") - shortcut.Arguments = "-m fishy" + + if anti_ghosting: + shortcut.TargetPath = r"C:\Windows\System32\cmd.exe" + python_dir = os.path.join(os.path.dirname(sys.executable), "pythonw.exe") + shortcut.Arguments = f"/C start /affinity 1 /low {python_dir} -m fishy" + else: + shortcut.TargetPath = os.path.join(os.path.dirname(sys.executable), "python.exe") + shortcut.Arguments = "-m fishy" + shortcut.IconLocation = manifest_file("icon.ico") shortcut.save() logging.info("Shortcut created") except Exception: + traceback.print_exc() logging.error("Couldn't create shortcut") diff --git a/fishy/sound.mp3 b/fishy/sound.mp3 new file mode 100644 index 0000000..79bd139 Binary files /dev/null and b/fishy/sound.mp3 differ diff --git a/requirements.txt b/requirements.txt index a0d8e0c..cdcf764 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,4 +12,5 @@ beautifulsoup4 whatsmyip pynput pytesseract -keyboard \ No newline at end of file +keyboard +playsound \ No newline at end of file