fork/Slippi-Presence

git clone https://git.julia.blue/fork/Slippi-Presence

MiguelOopsie26a3a35

very-alpha
2.7 KiB97 linesraw
1from pypresence import Presence
2import time
3import glob
4import os
5from slippi import Game
6
7file = open('code.txt')
8code = file.read()
9file.close()
10file = open('path.txt')
11path = file.read()
12file.close()
13
14client_id = '638163525029724180' 
15RPC = Presence(client_id) 
16RPC.connect() 
17
18while True:
19    list_of_files = glob.glob(path + ".\*")
20    sorted_files = sorted(list_of_files, key=os.path.getctime)
21    game = Game(sorted_files[-2])
22    stage = str(game.start.stage)[6:]
23    playing_with = []
24    for player in game.metadata.players:
25        if player is None:
26            char = "fox"
27        elif player.netplay is None:
28            char = "fox"
29        else:
30            if str(player.netplay.code) == code:
31                char = str(list(player.characters.keys())[0])[16:]
32            else:
33                playing_with.append(player.netplay.code)
34    
35    if len(playing_with) == 1:
36        melee_type = "Melee Singles"
37    else:
38        melee_type = "Melee Doubles"
39
40
41    playing_with_str = "vs."
42    for person in playing_with:
43        playing_with_str += " " + person
44
45    try:
46        if char == "CAPTAIN_FALCON":
47            char_image = 'falcon'
48            char_text = 'Captain Falcon'
49        elif char == "ICE_CLIMBERS":
50            char_image = 'iceclimbers'
51            char_text = "Ice Climbers"
52        elif char == "DONKEY_KONG":
53            char_image = "donkeykong"
54            char_text = 'Donkey Kong'
55        elif char == "GAME_AND_WATCH":
56            char_image = 'gaw'
57            char_text = "Mr. Game and Watch"
58        elif char == "YOUNG_LINK":
59            char_image = 'younglink'
60            char_text == "Young Link"
61        elif char == "DR_MARIO":
62            char_image = 'drmario'
63            char_text == "Doctor Mario"
64        else:
65            char_image = char.lower()
66            char_text = char.capitalize()
67        
68    except:
69        continue
70
71
72    if stage == "POKEMON_STADIUM":
73        stage_text = "Pokemon Stadium"
74        stage_image = "ps"
75    elif stage == "FOUNTAIN_OF_DREAMS":
76        stage_text = "Fountain of Dreams"
77        stage_image = "fod"
78    elif stage == "YOSHIS_STORY":
79        stage_text = "Yoshi's Story"
80        stage_image = "yoshis"
81    elif stage == "DREAM_LAND_N64":
82        stage_text = "Dreamland"
83        stage_image = "dl"
84    elif stage == "BATTLEFIELD":
85        stage_text = "Battlefield"
86        stage_image = "bf"
87    elif stage == "FINAL_DESTINATION":
88        stage_text = "Final Destination"
89        stage_image = "fd"
90
91
92    print(RPC.update(state=playing_with_str, details=melee_type, large_image=stage_image, small_image=char_image, large_text=stage_text, small_text=char_text, buttons=[{'label':'On testing',"url":'https://github.com/miguelrcborges/'}]))
93    time.sleep(10)
94
95
96
97