play sound when fish hole complete feature, normal and anti-lag shortcut options

This commit is contained in:
Adam Saudagar 2020-10-13 19:19:39 +05:30
parent 2d49d74af2
commit 21065e55ee
11 changed files with 66 additions and 9 deletions

View File

@ -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__

View File

@ -1,2 +1,2 @@
from fishy.__main__ import main
__version__ = "0.3.11"
__version__ = "0.3.13"

View File

@ -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()

View File

@ -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)

View File

@ -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")

View File

@ -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()

View File

@ -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))

31
fishy/gui/splash.py Normal file
View File

@ -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()

View File

@ -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")

BIN
fishy/sound.mp3 Normal file

Binary file not shown.

View File

@ -12,4 +12,5 @@ beautifulsoup4
whatsmyip
pynput
pytesseract
keyboard
keyboard
playsound