fork/Slippi-Presence
git clone https://git.julia.blue/fork/Slippi-Presence
4a1f07c
maybe-final
1import time 2import configparser 3import glob 4import os 5from slippi import Game 6from pypresence import Presence 7 8config = configparser .ConfigParser () 9config .read ('config.ini' ) 10path = config ['Variables' ]['path' ] 11code = config ['Variables' ]['code' ].upper () 12 13support_dict = {"CAPTAIN_FALCON" :['falcon' ,'Captain Falcon' ],"ICE_CLIMBERS" : ['iceclimbers' ,"Ice Climbers" ],"DONKEY_KONG" : ["donkeykong" ,"Donkey Kong" ],"GAME_AND_WATCH" : ['gaw' ,"Mr. Game and Watch" ],"YOUNG_LINK" : ['younglink' ,"Young Link" ],"DR_MARIO" : ['drmario' ,"Doctor Mario" ]} 14stages_dict = {"POKEMON_STADIUM" : ['ps' ,'Pokemon Stadium' ],"FOUNTAIN_OF_DREAMS" : ['fod' ,'Fountain of Dreams' ],"YOSHIS_STORY" : ["yoshis" ,"Yoshi's Story" ],"DREAM_LAND_N64" : ['dl' ,'Dreamland' ],"BATTLEFIELD" : ['bf' ,"Battlefield" ],"FINAL_DESTINATION" : ['fd' ,'Final Destination' ]} 15 16client_id = '638163525029724180' 17RPC = Presence (client_id ) 18RPC .connect () 19 20while True : 21list_of_files = glob .glob (path + "/*" ) 22sorted_files = sorted (list_of_files ,key = os .path .getctime ) 23game = Game (sorted_files [- 2 ]) 24stage = str (game .start .stage )[6 :] 25playing_with = [] 26for player in game .metadata .players : 27if player is None : 28pass 29else : 30if str (player .netplay .code )== code : 31char = str (list (player .characters .keys ())[0 ])[16 :] 32else : 33playing_with .append (player .netplay .code ) 34 35if len (playing_with )== 1 : 36melee_type = "Melee Singles" 37else : 38melee_type = "Melee Doubles" 39 40 41playing_with_str = "vs." 42for person in playing_with : 43playing_with_str += " " + person 44 45try : 46if char in support_dict .keys (): 47char_image ,char_text = support_dict [char ] 48else : 49char_image = char .lower () 50char_text = char .capitalize () 51 52except : 53continue 54 55try : 56stage_image ,stage_text = stages_dict [stage ] 57 58except : 59pass 60 61 62RPC .update (state = playing_with_str ,details = melee_type ,large_image = stage_image ,small_image = char_image ,large_text = stage_text ,small_text = char_text )) 63time .sleep (10 ) 64 65 66 67