Compare commits
7 Commits
e09c2ebd5b
...
1.1.1
Author | SHA1 | Date | |
---|---|---|---|
603a169c39 | |||
a9db65f8b6 | |||
f1ce1bff30 | |||
7ea995f1ec | |||
cee70ab57d | |||
d66becf13a | |||
e61029fdf5 |
14
.gitignore
vendored
14
.gitignore
vendored
@ -1,10 +1,22 @@
|
||||
# Config
|
||||
config.ini
|
||||
|
||||
# Environment
|
||||
.env/
|
||||
|
||||
# Database
|
||||
db.sqlite3
|
||||
|
||||
# Build garbage
|
||||
__pycache__/
|
||||
migrations/
|
||||
build/
|
||||
dist/
|
||||
main.spec
|
||||
|
||||
# VSCode garbage
|
||||
.vscode/
|
||||
|
||||
src/client/riotgames.pem
|
||||
# LCU_connector leftover
|
||||
riotgames.pem
|
||||
test.py
|
||||
|
@ -1,6 +1,8 @@
|
||||
# custoMM
|
||||
<p align="center">
|
||||
<img src="images/logo.png"/>
|
||||
<img src="images/logo.png"/><br>
|
||||
<img alt="Python => 3.11" src="https://img.shields.io/badge/Python-%3E%3D3.11-green)"/>
|
||||
<img alt="Version 1.1.1" src="https://img.shields.io/badge/Version-1.1.1-blueviolet" />
|
||||
</p>
|
||||
|
||||
|
||||
|
@ -1,25 +0,0 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIEIDCCAwgCCQDJC+QAdVx4UDANBgkqhkiG9w0BAQUFADCB0TELMAkGA1UEBhMC
|
||||
VVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFTATBgNVBAcTDFNhbnRhIE1vbmljYTET
|
||||
MBEGA1UEChMKUmlvdCBHYW1lczEdMBsGA1UECxMUTG9MIEdhbWUgRW5naW5lZXJp
|
||||
bmcxMzAxBgNVBAMTKkxvTCBHYW1lIEVuZ2luZWVyaW5nIENlcnRpZmljYXRlIEF1
|
||||
dGhvcml0eTEtMCsGCSqGSIb3DQEJARYeZ2FtZXRlY2hub2xvZ2llc0ByaW90Z2Ft
|
||||
ZXMuY29tMB4XDTEzMTIwNDAwNDgzOVoXDTQzM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7+uGlS1+5
|
||||
EcGfKZ+g024k/J32XP4hdho7WYAS2xMiV83CfLR/MNi8oSMaVQTdKD8cpgiWJk3L
|
||||
XWehWA==
|
||||
-----END CERTIFICATE-----
|
@ -13,12 +13,25 @@ SITE_URL = "your-server.com"
|
||||
```
|
||||
|
||||
## Releases
|
||||
Check out the releases for pre-compiled binaries of the client and server.
|
||||
Check out the releases for pre-compiled binaries/installers of the client. Remember to edit the config.ini file before running. That will be done in the setup, but still.
|
||||
|
||||
## TODOs
|
||||
## Manual compilationn
|
||||
Compile the client like so.
|
||||
|
||||
1. [x] Make the server and client talk to each other
|
||||
* [x] Based on MMR
|
||||
* [x] Based on cached IDs
|
||||
Firstly, check if your Python version is => 3.11
|
||||
```
|
||||
$ python --version
|
||||
> Python 3.11.3
|
||||
```
|
||||
Then, clone the repository.
|
||||
`$ git clone https://github.com/confestim/custoMM`
|
||||
`$ cd custoMM/src/client`
|
||||
If you don't have pyinstaller installed, do:
|
||||
`$ pip install pyinstaller`
|
||||
Once that's ready, you're ready to compile!
|
||||
`$ python -m PyInstaller --onefile main.py`
|
||||
|
||||
The exe file will reside in the newly created dist/ folder. Don't forget to copy the assets and the config to the same folder that your EXE resides(that means you will have to send them over to your friends along with the EXE file):
|
||||
`cp assets ../config.ini dist`
|
||||
|
||||
|
||||
|
@ -59,9 +59,11 @@ class Game:
|
||||
# Starts champ select
|
||||
return self.connection.post("/lol-lobby/v1/lobby/custom/start-champ-select", data={})
|
||||
|
||||
def move(self, team:str):
|
||||
def move(self):
|
||||
return self.connection.post("/lol-lobby/v1/lobby/custom/switch-teams", data={})
|
||||
|
||||
def leave(self):
|
||||
return self.connection.delete("/lol-lobby/v2/lobby")
|
||||
def get_teams(self):
|
||||
# Gets team
|
||||
cfg = self.connection.get("/lol-lobby/v2/lobby").json()["gameConfig"]
|
||||
|
@ -1,16 +1,23 @@
|
||||
from time import sleep
|
||||
from threading import Thread
|
||||
from .Scraper import Scraper
|
||||
import logging
|
||||
|
||||
class PeriodicScraper(Thread):
|
||||
def __init__(self):
|
||||
Thread.__init__(self)
|
||||
self.daemon = True
|
||||
self.connector:Scraper = Scraper()
|
||||
self.start()
|
||||
self.closed = False
|
||||
|
||||
def run(self):
|
||||
self.connector.check_for_game()
|
||||
while True:
|
||||
if self.closed:
|
||||
self.connector.connection.stop()
|
||||
break
|
||||
|
||||
game_state = self.connector.check_for_game()
|
||||
|
||||
logging.info("Scraping...")
|
||||
self.connector.scrape()
|
||||
sleep(5 * 60)
|
||||
sleep(5)
|
@ -1,6 +1,6 @@
|
||||
from lcu_connector import Connector
|
||||
from lcu_connector.exceptions import ClientProcessError
|
||||
import asyncio
|
||||
import logging
|
||||
import requests
|
||||
import time, sys
|
||||
import json
|
||||
@ -20,7 +20,8 @@ class Scraper:
|
||||
|
||||
while not self.connection:
|
||||
try:
|
||||
self.connection = Connector(start=True)
|
||||
self.connection = Connector()
|
||||
self.connection.start()
|
||||
except ClientProcessError:
|
||||
print("League client not open, sleeping...")
|
||||
time.sleep(90)
|
||||
@ -127,7 +128,7 @@ class Scraper:
|
||||
# Case 2: It belongs to somebody
|
||||
if claimed['lol_id'] and claimed['lol']:
|
||||
|
||||
# Notify them (if that is the case) that we will do nothing about their new name (slight TODO).
|
||||
# Change name in db if different in-game
|
||||
if claimed['lol'] != self.summoner['displayName']:
|
||||
self.register_summoner(True, claimed)
|
||||
|
||||
@ -148,23 +149,31 @@ class Scraper:
|
||||
# This is buggy, try to find a better way to do this.
|
||||
# Like for example, letting team 1 pass first, and then team 2.
|
||||
local_teams = game.get_teams()
|
||||
print(local_teams[0], local_teams[1], checker["teams"][0], checker["teams"][1])
|
||||
|
||||
if name in local_teams[0] and not name in checker["teams"][0]:
|
||||
game.move("blue")
|
||||
print("blue")
|
||||
game.move()
|
||||
logging.info("Moving to Team 2")
|
||||
elif name in local_teams[1] and not name in checker["teams"][1]:
|
||||
game.move("red")
|
||||
print("red")
|
||||
game.move()
|
||||
logging.info("Moving to Team 1")
|
||||
|
||||
def start(self, checker, game):
|
||||
self.move_needed(checker, game, self.name)
|
||||
time.sleep(5)
|
||||
# Wait until there are 10 players(confirmed) in the lobby
|
||||
while requests.get(f"{self.URL}/current/{self.name}").json()["players"] != 10:
|
||||
print("Waiting for players...")
|
||||
timeout_counter = 0
|
||||
while response := requests.get(f"{self.URL}/current/{self.name}").json()["players"] != 10:
|
||||
logging.info("Waiting for players...")
|
||||
timeout_counter += 5
|
||||
if timeout_counter == 60:
|
||||
logging.info("Timeout, aborting...")
|
||||
break
|
||||
time.sleep(5)
|
||||
game.start()
|
||||
if response == 10:
|
||||
logging.info("Starting game...")
|
||||
game.start()
|
||||
else:
|
||||
game.leave()
|
||||
requests.delete(f"{self.URL}/current/{self.name}")
|
||||
|
||||
def check_for_game(self):
|
||||
@ -246,5 +255,4 @@ class Scraper:
|
||||
if req.status_code == 500:
|
||||
print("Serverside error! Contact maintainer!")
|
||||
|
||||
self.connection.stop()
|
||||
return len(games)
|
||||
|
@ -1,15 +1,15 @@
|
||||
import pystray
|
||||
from PIL import Image
|
||||
from .Scraper import Scraper
|
||||
image = Image.open("assets/icon.png")
|
||||
import pyautogui
|
||||
from time import sleep
|
||||
import logging
|
||||
|
||||
class UI():
|
||||
|
||||
def __init__(self,scraper):
|
||||
def __init__(self,scraper, periodic, parent):
|
||||
image = Image.open(parent + "\\assets\\icon.png")
|
||||
|
||||
self.periodic = periodic
|
||||
self.menu = pystray.Menu(
|
||||
pystray.MenuItem(
|
||||
"Check registration", self.check_registration, default=True
|
||||
@ -30,6 +30,7 @@ class UI():
|
||||
self.check_registration()
|
||||
self.icon.run_detached()
|
||||
|
||||
|
||||
def check(self):
|
||||
self.icon.notify("This is discouraged, as it is done automatically anyway.", "Checking for game...")
|
||||
game = self.scraper.check_for_game()
|
||||
@ -42,7 +43,6 @@ class UI():
|
||||
|
||||
def report(self):
|
||||
self.icon.notify("Game report initiated.")
|
||||
logging.warning(self.icon)
|
||||
self.scraper.scrape()
|
||||
self.icon.notify("Game reported", "Your game has been reported to the server.")
|
||||
|
||||
@ -65,4 +65,5 @@ class UI():
|
||||
|
||||
def quit(self, icon, query):
|
||||
icon.stop()
|
||||
self.periodic.closed = True
|
||||
|
||||
|
@ -2,9 +2,10 @@ import requests
|
||||
|
||||
# Edit config.ini when running for the first time
|
||||
import sys
|
||||
import os
|
||||
import configparser
|
||||
from time import sleep
|
||||
import threading
|
||||
import logging
|
||||
|
||||
# Custom imports
|
||||
from classes.Util import WhatTheFuckDidYouDo
|
||||
@ -13,9 +14,12 @@ from classes.PeriodicScraper import PeriodicScraper
|
||||
from classes.Scraper import Scraper
|
||||
|
||||
# Config section
|
||||
parent = os.path.dirname(os.path.abspath(__file__))
|
||||
config = configparser.ConfigParser()
|
||||
config.read("../config.ini")
|
||||
logging.info(parent + "\\config.ini")
|
||||
print(parent + "\\config.ini")
|
||||
URL = config["DEFAULT"]["URL"]
|
||||
logging.basicConfig(format='%(asctime)s - %(message)s', level=logging.INFO)
|
||||
|
||||
# Test connection to server
|
||||
try:
|
||||
@ -31,12 +35,11 @@ except Exception:
|
||||
def main():
|
||||
# Match scraping
|
||||
# Running the UI
|
||||
ui = UI(scraper=Scraper())
|
||||
scraper = Scraper(ui=ui)
|
||||
periodic = PeriodicScraper()
|
||||
ui = UI(scraper=periodic.connector, periodic=periodic, parent=parent)
|
||||
periodic.start()
|
||||
periodic.join()
|
||||
|
||||
# Loop until close, let stuff kill itself
|
||||
while threading.active_count() >= 3:
|
||||
sleep(10)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@ -54,8 +54,7 @@ class CurrentViewSet(viewsets.ModelViewSet):
|
||||
return Response(serializer.data)
|
||||
|
||||
def delete(self, request, *args, **kwargs):
|
||||
discord_id = kwargs.get('pk')
|
||||
instance = Current.objects.get(creator=creator)
|
||||
instance = Current.objects.get(creator=request.data.get("creator"))
|
||||
self.perform_destroy(instance)
|
||||
return Response(status=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
|
Reference in New Issue
Block a user