diff --git a/server/nightr/strategies/upstairs_neighbour.py b/server/nightr/strategies/upstairs_neighbour.py new file mode 100644 index 0000000..51ba11c --- /dev/null +++ b/server/nightr/strategies/upstairs_neighbour.py @@ -0,0 +1,35 @@ +import requests +from bs4 import BeautifulSoup +from datetime import datetime + +from ..util import Prediction, Context + + +def update(): + requests.post('https://euw.op.gg/summoner/ajax/renew.json/', data = {'summonerId': 34009256}) + + +def check_games(context: Context) -> Prediction: + update() + r = requests.get('https://euw.op.gg/summoner/userName=Im+Eating+Pros') + + #if not "is not in an active game" in str(r.content): + # return 1.0 + + p = Prediction() + + soup = BeautifulSoup(r.content, features='html5lib') + + timestamp = int(soup.find('div', {'class': 'GameItemList'}).find('div', {'class': 'GameItem'})['data-game-time']) + last_played_game = datetime.fromtimestamp(timestamp) + + last_game_in_hours = (((datetime.now() - last_played_game).seconds)/60/60) + + if last_game_in_hours < 2: + p.reasons.append("Alexanders upstairs neighbour is currently playing league") + p.probability = 0.8 + else: + p.reasons.append(f"Alexanders upstairs neighbour has not played league for {last_game_in_hours} hours!") + p.probability = last_game_in_hours / 24 + + return p