initial commit
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
env/*
|
||||||
39
api_test.py
Normal file
39
api_test.py
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import requests
|
||||||
|
import time
|
||||||
|
import json
|
||||||
|
from pypresence import Presence
|
||||||
|
from pypresence.types import ActivityType, StatusDisplayType
|
||||||
|
|
||||||
|
client_id = "1439626657978646559"
|
||||||
|
RPC = Presence(client_id)
|
||||||
|
RPC.connect()
|
||||||
|
|
||||||
|
def get_game_data():
|
||||||
|
try:
|
||||||
|
response = requests.get('https://127.0.0.1:2999/liveclientdata/allgamedata',
|
||||||
|
verify=False,
|
||||||
|
timeout=2)
|
||||||
|
return response.json()
|
||||||
|
except requests.exceptions.RequestException:
|
||||||
|
return None
|
||||||
|
|
||||||
|
while True:
|
||||||
|
data = get_game_data()
|
||||||
|
|
||||||
|
if data is None:
|
||||||
|
print("League isn't running or no game active")
|
||||||
|
time.sleep(3) # Poll every 3 seconds, reasonable limit for riot api
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Parse and do stuff with data here
|
||||||
|
game_time = data['gameData']['gameTime']
|
||||||
|
print(f"Game time: {game_time:.0f}s")
|
||||||
|
|
||||||
|
# Show as "Listening to" instead of "Playing"
|
||||||
|
RPC.update(
|
||||||
|
activity_type=ActivityType.PLAYING,
|
||||||
|
details="My Favorite Song",
|
||||||
|
state="By My Favorite Artist"
|
||||||
|
)
|
||||||
|
|
||||||
|
time.sleep(15) # Poll every 15 seconds (discord update limit)
|
||||||
BIN
assets/lol-icon.jpg
Normal file
BIN
assets/lol-icon.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.4 KiB |
BIN
requirements.txt
Normal file
BIN
requirements.txt
Normal file
Binary file not shown.
Reference in New Issue
Block a user