Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 9d3caf2

Browse files
committed
changed event listening
1 parent db0a71d commit 9d3caf2

File tree

5 files changed

+23
-10
lines changed

5 files changed

+23
-10
lines changed

__pycache__/utils.cpython-38.pyc

14 Bytes
Binary file not shown.

dist/library.zip

0 Bytes
Binary file not shown.

dist/main.exe

0 Bytes
Binary file not shown.

main.py

+22-9
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020
client_id = "811469787657928704"
2121
RPC = Presence(client_id)
2222

23-
last_state = ""
24-
last_queue_time = ""
25-
stop_time = True
23+
last_presence = {}
2624

2725
def is_process_running(required_processes=["VALORANT.exe", "RiotClientServices.exe"]):
2826
processes = []
@@ -75,6 +73,7 @@ def update_rpc(state):
7573
small_text="Party Leader" if utils.validate_party_size(data) else None,
7674
party_id=data["partyId"],
7775
party_size=party_size,
76+
buttons=[{"label":"test","url":"https://example.com"}]
7877
)
7978

8079
#custom setup
@@ -144,7 +143,7 @@ def update_rpc(state):
144143
small_image="away_icon",
145144
)
146145

147-
146+
'''
148147
async def listen():
149148
async with websockets.connect(f'wss://riot:{lockfile["password"]}@localhost:{lockfile["port"]}', ssl=ssl_context) as websocket:
150149
await websocket.send('[5, "OnJsonApiEvent_chat_v4_presences"]')
@@ -158,12 +157,26 @@ async def listen():
158157
if not is_process_running():
159158
print("valorant closed, exiting")
160159
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)
162175

163176
if __name__=="__main__":
164177

165178
if not is_process_running():
166-
print("valorant not opening, attempting to open...")
179+
print("valorant not opened, attempting to run...")
167180
subprocess.Popen([os.environ['RCS_PATH'], "--launch-product=valorant", "--launch-patchline=live"])
168181
while not is_process_running():
169182
print("waiting for valorant...")
@@ -180,17 +193,17 @@ async def listen():
180193
lockfile = api.get_lockfile()
181194
if lockfile is None:
182195
while lockfile is None:
183-
print("waiting for lockfile, retrying...")
196+
print("waiting for lockfile...")
184197
lockfile = api.get_lockfile()
185198
time.sleep(1)
186199
print("lockfile loaded!")
187200
presence = api.get_presence(lockfile)
188201
if presence is None:
189202
while presence is None:
190-
print("waiting for presence, retrying...")
203+
print("waiting for presence...")
191204
presence = api.get_presence(lockfile)
192205
time.sleep(1)
193206
update_rpc(presence)
194-
207+
print(f"LOCKFILE: {lockfile}")
195208
loop = asyncio.get_event_loop()
196209
loop.run_until_complete(listen())

utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"competitive":"mode_standard",
2222
"spike rush":"mode_spike_rush",
2323
"deathmatch":"mode_deathmatch",
24-
"ggteam":"mode_escalation",
24+
"escalation":"mode_escalation",
2525
"custom":"mode_standard",
2626
}
2727

0 commit comments

Comments
 (0)