Compare commits

...

3 Commits

Author SHA1 Message Date
boyan_k
0b6fb3379d Merge pull request 'Fixed file paths, LICENSE and README for client.' (#11) from windows into main
Reviewed-on: boyan_k/custoMM#11
2023-05-16 22:57:17 +02:00
confestim
41012f11c3 Fixed README and file paths, time to merge!😊 2023-05-16 22:55:08 +02:00
confestim
603a169c39 Windows folders :( 2023-05-16 21:33:25 +02:00
9 changed files with 80 additions and 38 deletions

18
.gitignore vendored
View File

@ -1,10 +1,22 @@
config.ini
# Config
src/config.ini
# Environment
.env/
# Database
db.sqlite3
# Build garbage
__pycache__/
migrations/
build/
dist/
.vscode/
riotgames.pem
main.spec
# VSCode garbage
.vscode/
# LCU_connector leftover
riotgames.pem
test.py

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) <year> <copyright holders>
Copyright (c) 2023 Boyan Karakostov
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

View File

@ -13,12 +13,27 @@ 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 --noconsole`
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`
From here, do whatever with the dist folder, I would recommend zipping it.

View File

@ -4,11 +4,8 @@ import configparser
from .Util import WhatTheFuckDidYouDo
class Game:
def __init__(self, *, loop=None, connection):
# Config
self.config = configparser.ConfigParser()
# Relative paths bad, fix this
self.config.read ("../config.ini")
def __init__(self, *, loop=None, connection,config):
self.config = config
self.URL = self.config["DEFAULT"]["URL"]
self.password = self.config["LEAGUE"]["LOBBY_PASS"]
# Loop until we get connection

View File

@ -4,10 +4,10 @@ from .Scraper import Scraper
import logging
class PeriodicScraper(Thread):
def __init__(self):
def __init__(self, config):
Thread.__init__(self)
self.daemon = True
self.connector:Scraper = Scraper()
self.connector:Scraper = Scraper(config=config)
self.closed = False
def run(self):

View File

@ -9,11 +9,10 @@ from .Util import WhatTheFuckDidYouDo
from .Game import Game
class Scraper:
def __init__(self, *, loop=None, ui=None):
def __init__(self, *, loop=None, ui=None, config):
self.ui = ui
self.config = configparser.ConfigParser()
self.config = config
# Relative paths bad, fix this
self.config.read ("../config.ini")
self.URL = self.config["DEFAULT"]["URL"]
# Loop until we get connection
self.connection = None
@ -184,7 +183,7 @@ class Scraper:
checker = requests.get(f"{self.URL}/current").json()[0]
except IndexError:
return "NO_GAME"
game = Game(connection=self.connection)
game = Game(connection=self.connection, config=self.config)
# If you are indeed the creator, create the game and disclose its name to the server
if checker["creator"] == self.name:

View File

@ -1,13 +1,16 @@
import pystray
from PIL import Image
from .Scraper import Scraper
image = Image.open("assets/icon.png")
import pyautogui
from time import sleep
import sys, os
class UI():
def __init__(self,scraper, periodic):
def __init__(self,scraper, periodic, base_dir):
image = Image.open(os.path.join(base_dir, os.path.join("assets", "icon.png")))
self.periodic = periodic
self.menu = pystray.Menu(
pystray.MenuItem(
@ -26,32 +29,32 @@ class UI():
self.icon = pystray.Icon(
"name", image, "CustoMM", self.menu)
self.scraper = scraper
self.check_registration()
self.icon.run_detached()
self.icon.notify("CustoMM is running in the background.", title="CustoMM")
self.check_registration()
def check(self):
self.icon.notify("This is discouraged, as it is done automatically anyway.", "Checking for game...")
self.icon.notify("This is discouraged, as it is done automatically anyway.", "Checking for game...", title="CustoMM")
game = self.scraper.check_for_game()
if game == "NO_GAME":
self.icon.notify("Please create a game on discord.", "No game found.")
self.icon.notify("Please create a game on discord.", "No game found.", title="CustoMM")
elif game == "CREATED":
self.icon.notify("GLHF!", "You are the host of a new game!",)
self.icon.notify("GLHF!", "You are the host of a new game!", title="CustoMM")
elif game == "JOINED":
self.icon.notify("Waiting for players...", "Game joined!")
self.icon.notify("Waiting for players...", "Game joined!", title="CustoMM")
def report(self):
self.icon.notify("Game report initiated.")
self.scraper.scrape()
self.icon.notify("Game reported", "Your game has been reported to the server.")
self.icon.notify("Game reported", "Your game has been reported to the server.", title="CustoMM")
def check_registration(self):
check = self.scraper.check_summoner()
if check == "USER_DOES_NOT_EXIST":
self.icon.notify("You are not registered, please register on the website.")
self.icon.notify("You are not registered, please register on the website.", title="CustoMM")
elif check == "UNCLAIMED":
self.icon.notify("You have not claimed your account yet, please claim it on discord -> !registed <ACCOUNT_NAME>.")
self.icon.notify("You have not claimed your account yet, please claim it on discord -> !registed <ACCOUNT_NAME>.", title="CustoMM")
elif check[0] == "REGISTRATION_IN_PROGRESS":
prompt = pyautogui.confirm(f"Your account is currently being registered by {check[1]}, do you want to proceed?")
if prompt:
@ -59,7 +62,7 @@ class UI():
else:
self.scraper.register_summoner(False, check[1])
else:
self.icon.notify(f"Your account is registered to {check[0]} and your account name is {check[1]}.")
self.icon.notify(f"Your account is registered to {check[0]} and your account name is {check[1]}.", title="CustoMM")
def quit(self, icon, query):

7
src/client/config.ini Normal file
View File

@ -0,0 +1,7 @@
[DEFAULT]
; Your URL here (with no slash at the end)
URL = http://change.me
[LEAGUE]
; Password for the generated league lobbies
LOBBY_PASS = password123

View File

@ -1,7 +1,7 @@
import requests
# Edit config.ini when running for the first time
import sys
import sys, os
import configparser
from time import sleep
import logging
@ -13,11 +13,20 @@ from classes.PeriodicScraper import PeriodicScraper
from classes.Scraper import Scraper
# Config section
config = configparser.ConfigParser()
config.read("../config.ini")
URL = config["DEFAULT"]["URL"]
logging.basicConfig(format='%(asctime)s - %(message)s', level=logging.INFO)
# Check if bundled
if getattr(sys, 'frozen', False):
base_dir = os.path.dirname(sys.executable)
elif __file__:
base_dir = os.path.dirname(__file__)
logging.info(base_dir)
config = configparser.ConfigParser()
conf_path = os.path.join(base_dir, "config.ini")
logging.info(conf_path)
config.read(conf_path)
URL = config["DEFAULT"]["URL"]
# Test connection to server
try:
test = requests.get(URL).json()
@ -32,8 +41,8 @@ except Exception:
def main():
# Match scraping
# Running the UI
periodic = PeriodicScraper()
ui = UI(scraper=periodic.connector, periodic=periodic)
periodic = PeriodicScraper(config=config)
ui = UI(scraper=periodic.connector, periodic=periodic, base_dir=base_dir)
periodic.start()
periodic.join()