2020-05-05 15:11:00 +00:00
|
|
|
import ctypes
|
2020-04-19 11:52:42 +00:00
|
|
|
import logging
|
2020-05-05 15:11:00 +00:00
|
|
|
import os
|
2020-04-19 11:52:42 +00:00
|
|
|
import sys
|
2020-06-25 18:43:53 +00:00
|
|
|
import traceback
|
2020-04-19 11:52:42 +00:00
|
|
|
import win32con
|
|
|
|
import win32gui
|
2020-04-18 11:32:14 +00:00
|
|
|
|
2020-04-19 11:52:42 +00:00
|
|
|
import fishy
|
2020-05-14 02:03:13 +00:00
|
|
|
from fishy import web, helper, gui
|
2020-10-17 10:52:04 +00:00
|
|
|
from fishy.engine.common.event_handler import EngineEventHandler
|
2021-02-14 18:07:49 +00:00
|
|
|
from fishy.gui import GUI, splash, update_dialog
|
2020-10-17 19:06:07 +00:00
|
|
|
from fishy.helper import hotkey
|
|
|
|
from fishy.helper.config import config
|
2021-03-24 16:58:35 +00:00
|
|
|
from fishy.constants import chalutier, lam2
|
2020-04-27 21:19:30 +00:00
|
|
|
|
|
|
|
|
2020-06-27 15:23:32 +00:00
|
|
|
def check_window_name(title):
|
|
|
|
titles = ["Command Prompt", "PowerShell", "Fishy"]
|
|
|
|
for t in titles:
|
|
|
|
if t in title:
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
2020-05-14 02:03:13 +00:00
|
|
|
# noinspection PyBroadException
|
2020-10-17 19:06:07 +00:00
|
|
|
def initialize(window_to_hide):
|
|
|
|
helper.create_shortcut_first()
|
|
|
|
helper.initialize_uid()
|
2020-04-19 11:52:42 +00:00
|
|
|
|
2020-10-17 19:06:07 +00:00
|
|
|
new_session = web.get_session()
|
2020-05-05 12:55:06 +00:00
|
|
|
if new_session is None:
|
|
|
|
logging.error("Couldn't create a session, some features might not work")
|
|
|
|
print(f"created session {new_session}")
|
|
|
|
|
2020-05-05 15:11:00 +00:00
|
|
|
try:
|
|
|
|
is_admin = os.getuid() == 0
|
|
|
|
except AttributeError:
|
|
|
|
is_admin = ctypes.windll.shell32.IsUserAnAdmin() != 0
|
2020-06-03 01:41:54 +00:00
|
|
|
if is_admin:
|
2020-05-05 15:11:00 +00:00
|
|
|
logging.info("Running with admin privileges")
|
|
|
|
|
2020-04-19 11:52:42 +00:00
|
|
|
try:
|
2021-02-14 18:07:49 +00:00
|
|
|
if helper.upgrade_avail() and not config.get("dont_ask_update", False):
|
|
|
|
cv,hv = helper.versions()
|
|
|
|
update_now, dont_ask_update = update_dialog.start(cv,hv)
|
|
|
|
if dont_ask_update:
|
|
|
|
config.set("dont_ask_update", dont_ask_update)
|
|
|
|
else:
|
|
|
|
config.delete("dont_ask_update")
|
|
|
|
|
|
|
|
if update_now:
|
|
|
|
helper.auto_upgrade()
|
2020-04-19 11:52:42 +00:00
|
|
|
except Exception:
|
2020-06-25 18:43:53 +00:00
|
|
|
logging.error(traceback.format_exc())
|
2020-04-19 11:52:42 +00:00
|
|
|
|
2020-10-17 19:06:07 +00:00
|
|
|
if not config.get("debug", False) and check_window_name(win32gui.GetWindowText(window_to_hide)):
|
2020-05-14 02:03:13 +00:00
|
|
|
win32gui.ShowWindow(window_to_hide, win32con.SW_HIDE)
|
2020-04-19 11:52:42 +00:00
|
|
|
helper.install_thread_excepthook()
|
|
|
|
sys.excepthook = helper.unhandled_exception_logging
|
|
|
|
|
2021-03-24 16:58:35 +00:00
|
|
|
if not config.get("addoninstalled", False) and not helper.addon_exists(chalutier[0]):
|
|
|
|
helper.install_addon(*chalutier)
|
|
|
|
helper.install_addon(*lam2)
|
|
|
|
config.set("addoninstalled", True)
|
2020-06-25 01:22:39 +00:00
|
|
|
|
2020-04-20 19:46:12 +00:00
|
|
|
|
2020-04-19 11:52:42 +00:00
|
|
|
def main():
|
2020-10-13 13:49:39 +00:00
|
|
|
splash.start()
|
2020-05-07 06:03:30 +00:00
|
|
|
print("launching please wait...")
|
|
|
|
|
2020-10-13 13:49:39 +00:00
|
|
|
pil_logger = logging.getLogger('PIL')
|
|
|
|
pil_logger.setLevel(logging.INFO)
|
|
|
|
|
2020-05-14 02:03:13 +00:00
|
|
|
window_to_hide = win32gui.GetForegroundWindow()
|
2020-05-05 12:55:06 +00:00
|
|
|
|
2020-10-17 19:06:07 +00:00
|
|
|
if not gui.check_eula():
|
2020-05-05 12:55:06 +00:00
|
|
|
return
|
|
|
|
|
2020-10-17 19:06:07 +00:00
|
|
|
bot = EngineEventHandler(lambda: gui_window)
|
|
|
|
gui_window = GUI(lambda: bot)
|
2020-05-19 03:11:58 +00:00
|
|
|
|
2020-06-25 18:43:53 +00:00
|
|
|
hotkey.initalize()
|
2020-06-25 16:39:05 +00:00
|
|
|
|
2020-05-05 12:55:06 +00:00
|
|
|
logging.info(f"Fishybot v{fishy.__version__}")
|
2020-10-17 19:06:07 +00:00
|
|
|
initialize(window_to_hide)
|
2020-04-18 11:32:14 +00:00
|
|
|
|
2021-02-14 18:07:12 +00:00
|
|
|
gui_window.start()
|
|
|
|
|
2020-04-19 11:52:42 +00:00
|
|
|
bot.start_event_handler()
|
2020-04-15 11:27:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|