mirror of
https://github.com/fishyboteso/fishyboteso.git
synced 2024-08-30 18:32:13 +00:00
0.3.0 final
- build now deletes old version before building the new one - prints lauching before initializing - removed multithreading from config saving - better logic for fising interupted - fix terms link bug - now prints exception during web calls - removes the uid if not found during get_session
This commit is contained in:
parent
79c7f748e1
commit
066c25f08a
@ -11,8 +11,9 @@ Don't forget to star this repository if you really liked it :)
|
||||
### How to Install?
|
||||
|
||||
- Install [Python v3.7.3](https://www.python.org/downloads/release/python-373/) (make sure you tick, `Add Python to PATH`)
|
||||
- Then open PowerShell and type these commands,
|
||||
- Then open PowerShell and type these commands, one by one,
|
||||
```
|
||||
python -m pip install pip --upgrade
|
||||
pip install fishy
|
||||
python -m fishy
|
||||
```
|
||||
|
@ -1,4 +1,5 @@
|
||||
@echo off
|
||||
rd build dist /s /q
|
||||
call activate ./venv
|
||||
python ./setup.py sdist
|
||||
python ./setup.py bdist_wheel
|
||||
|
@ -3,7 +3,6 @@ import logging
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
from os import execl
|
||||
from tkinter import messagebox
|
||||
|
||||
import win32con
|
||||
@ -127,7 +126,7 @@ def initialize(gui, c: Config):
|
||||
create_shortcut_first(gui, c)
|
||||
initialize_uid(c)
|
||||
|
||||
new_session = web.get_session(c.get('uid'))
|
||||
new_session = web.get_session(c)
|
||||
if new_session is None:
|
||||
logging.error("Couldn't create a session, some features might not work")
|
||||
print(f"created session {new_session}")
|
||||
@ -171,6 +170,8 @@ def ask_terms():
|
||||
|
||||
|
||||
def main():
|
||||
print("launching please wait...")
|
||||
|
||||
c = Config()
|
||||
|
||||
if not check_eula(c):
|
||||
|
@ -20,9 +20,11 @@ class Config:
|
||||
if save:
|
||||
self.save_config()
|
||||
|
||||
def delete(self, key):
|
||||
del self.config_dict[key]
|
||||
self.save_config()
|
||||
|
||||
def save_config(self):
|
||||
def save():
|
||||
with open(filename, 'w') as f:
|
||||
f.write(json.dumps(self.config_dict))
|
||||
|
||||
Thread(target=save).start()
|
||||
|
@ -87,11 +87,13 @@ class IdleEvent(FishEvent):
|
||||
:param previousMode: previous mode in the state machine
|
||||
"""
|
||||
|
||||
if previousMode.name == "hook":
|
||||
logging.info("HOLE DEPLETED")
|
||||
if G.fishCaught > 0:
|
||||
web.send_hole_deplete(self.uid, G.fishCaught, time.time() - G.hole_start_time, G.fish_times)
|
||||
G.fishCaught = 0
|
||||
elif previousMode.name == "stick":
|
||||
|
||||
if previousMode.name == "hook":
|
||||
logging.info("HOLE DEPLETED")
|
||||
else:
|
||||
logging.info("FISHING INTERRUPTED")
|
||||
|
||||
def onExitCallback(self, currentMode):
|
||||
|
@ -88,7 +88,7 @@ def _formatHyperLink(text, message):
|
||||
lambda *a, **k: text.config(cursor="arrow"))
|
||||
text.tag_bind(str(index),
|
||||
"<Button-1>",
|
||||
lambda: webbrowser.open(groups['address']))
|
||||
lambda x: webbrowser.open(groups['address']))
|
||||
start = match.end()
|
||||
else:
|
||||
text.insert("end", message[start:])
|
||||
|
@ -1,14 +1,16 @@
|
||||
import logging
|
||||
import traceback
|
||||
from functools import wraps
|
||||
|
||||
import requests
|
||||
from whatsmyip.ip import get_ip
|
||||
from whatsmyip.providers import GoogleDnsProvider
|
||||
|
||||
from fishy.systems import helper
|
||||
from fishy.systems.globals import G
|
||||
|
||||
# domain = "https://fishyeso.herokuapp.com"
|
||||
domain = "http://127.0.0.1:5000"
|
||||
domain = "https://fishyeso.herokuapp.com"
|
||||
# domain = "http://127.0.0.1:5000"
|
||||
|
||||
user = "/api/user"
|
||||
notify = "/api/notify"
|
||||
@ -37,8 +39,8 @@ def fallback(default):
|
||||
try:
|
||||
return f(*args, **kwargs)
|
||||
except:
|
||||
traceback.print_exc()
|
||||
return default
|
||||
|
||||
return wrapper
|
||||
|
||||
return inner
|
||||
@ -105,11 +107,17 @@ def unsub(uid):
|
||||
|
||||
|
||||
@fallback(None)
|
||||
def get_session(uid, lazy=True):
|
||||
def get_session(config, lazy=True):
|
||||
if lazy and G._session_id is not None:
|
||||
return G._session_id
|
||||
|
||||
body = {"uid": uid}
|
||||
body = {"uid": config.get("uid")}
|
||||
response = requests.post(domain + session, params=body)
|
||||
|
||||
if response.status_code == 405:
|
||||
config.delete("uid")
|
||||
helper.restart()
|
||||
return None
|
||||
|
||||
G._session_id = response.json()["session_id"]
|
||||
return G._session_id
|
||||
|
Loading…
Reference in New Issue
Block a user