20
20
client_id = "811469787657928704"
21
21
RPC = Presence (client_id )
22
22
23
- last_state = ""
24
- last_queue_time = ""
25
- stop_time = True
23
+ last_presence = {}
26
24
27
25
def is_process_running (required_processes = ["VALORANT.exe" , "RiotClientServices.exe" ]):
28
26
processes = []
@@ -75,6 +73,7 @@ def update_rpc(state):
75
73
small_text = "Party Leader" if utils .validate_party_size (data ) else None ,
76
74
party_id = data ["partyId" ],
77
75
party_size = party_size ,
76
+ buttons = [{"label" :"test" ,"url" :"https://example.com" }]
78
77
)
79
78
80
79
#custom setup
@@ -144,7 +143,7 @@ def update_rpc(state):
144
143
small_image = "away_icon" ,
145
144
)
146
145
147
-
146
+ '''
148
147
async def listen():
149
148
async with websockets.connect(f'wss://riot:{lockfile["password"]}@localhost:{lockfile["port"]}', ssl=ssl_context) as websocket:
150
149
await websocket.send('[5, "OnJsonApiEvent_chat_v4_presences"]')
@@ -158,12 +157,26 @@ async def listen():
158
157
if not is_process_running():
159
158
print("valorant closed, exiting")
160
159
quit()
161
-
160
+ '''
161
+
162
+ def listen ():
163
+ global last_presence
164
+ while True :
165
+ if not is_process_running ():
166
+ print ("valorant closed, exiting" )
167
+ quit ()
168
+ presence = api .get_presence (lockfile )
169
+ if presence == last_presence :
170
+ last_presence = presence
171
+ continue
172
+ update_rpc (presence )
173
+ last_presence = presence
174
+ time .sleep (1 )
162
175
163
176
if __name__ == "__main__" :
164
177
165
178
if not is_process_running ():
166
- print ("valorant not opening , attempting to open ..." )
179
+ print ("valorant not opened , attempting to run ..." )
167
180
subprocess .Popen ([os .environ ['RCS_PATH' ], "--launch-product=valorant" , "--launch-patchline=live" ])
168
181
while not is_process_running ():
169
182
print ("waiting for valorant..." )
@@ -180,17 +193,17 @@ async def listen():
180
193
lockfile = api .get_lockfile ()
181
194
if lockfile is None :
182
195
while lockfile is None :
183
- print ("waiting for lockfile, retrying ..." )
196
+ print ("waiting for lockfile..." )
184
197
lockfile = api .get_lockfile ()
185
198
time .sleep (1 )
186
199
print ("lockfile loaded!" )
187
200
presence = api .get_presence (lockfile )
188
201
if presence is None :
189
202
while presence is None :
190
- print ("waiting for presence, retrying ..." )
203
+ print ("waiting for presence..." )
191
204
presence = api .get_presence (lockfile )
192
205
time .sleep (1 )
193
206
update_rpc (presence )
194
-
207
+ print ( f"LOCKFILE: { lockfile } " )
195
208
loop = asyncio .get_event_loop ()
196
209
loop .run_until_complete (listen ())
0 commit comments