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-05-05 12:55:06 +00:00
|
|
|
|
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-06-01 12:58:18 +00:00
|
|
|
from fishy.engine.event_handler import EngineEventHandler
|
2020-05-14 02:03:13 +00:00
|
|
|
from fishy.gui import GUI
|
|
|
|
from fishy.helper import Config
|
2020-04-27 21:19:30 +00:00
|
|
|
|
|
|
|
|
2020-05-14 02:03:13 +00:00
|
|
|
# noinspection PyBroadException
|
|
|
|
def initialize(c: Config, window_to_hide):
|
|
|
|
helper.create_shortcut_first(c)
|
|
|
|
helper.initialize_uid(c)
|
2020-04-19 11:52:42 +00:00
|
|
|
|
2020-05-07 06:03:30 +00:00
|
|
|
new_session = web.get_session(c)
|
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:
|
2020-05-14 02:03:13 +00:00
|
|
|
helper.auto_upgrade()
|
2020-04-19 11:52:42 +00:00
|
|
|
except Exception:
|
|
|
|
pass
|
|
|
|
|
|
|
|
if not c.get("debug", False):
|
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
|
|
|
|
|
2020-06-25 01:22:39 +00:00
|
|
|
helper.check_addon("ProvisionsChalutier")
|
|
|
|
|
|
|
|
if c.get("debug", False):
|
|
|
|
helper.check_addon("FooAddon")
|
2020-04-27 21:19:30 +00:00
|
|
|
|
2020-04-20 19:46:12 +00:00
|
|
|
|
2020-04-19 11:52:42 +00:00
|
|
|
def main():
|
2020-05-07 06:03:30 +00:00
|
|
|
print("launching please wait...")
|
|
|
|
|
2020-05-14 02:03:13 +00:00
|
|
|
window_to_hide = win32gui.GetForegroundWindow()
|
2020-04-19 11:52:42 +00:00
|
|
|
c = Config()
|
2020-05-05 12:55:06 +00:00
|
|
|
|
2020-05-14 02:03:13 +00:00
|
|
|
if not gui.check_eula(c):
|
2020-05-05 12:55:06 +00:00
|
|
|
return
|
|
|
|
|
2020-06-01 12:58:18 +00:00
|
|
|
bot = EngineEventHandler(c, lambda: gui_window)
|
2020-05-19 03:11:58 +00:00
|
|
|
gui_window = GUI(c, lambda: bot)
|
|
|
|
|
2020-05-14 02:03:13 +00:00
|
|
|
gui_window.start()
|
2020-04-18 04:21:18 +00:00
|
|
|
|
2020-05-05 12:55:06 +00:00
|
|
|
logging.info(f"Fishybot v{fishy.__version__}")
|
2020-05-14 02:03:13 +00:00
|
|
|
initialize(c, window_to_hide)
|
2020-04-18 11:32:14 +00:00
|
|
|
|
2020-04-19 11:52:42 +00:00
|
|
|
bot.start_event_handler()
|
2020-04-15 11:27:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|