forked from nadir/adobe-rpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rpc.py
48 lines (42 loc) · 1.25 KB
/
rpc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from pypresence import Presence
import handler
import time
client_id = "482150417455775755"
rich_presence = Presence(client_id)
def connect():
return rich_presence.connect()
def connect_loop(retries=0):
if retries > 10:
return
try:
connect()
except:
print("Error connecting to Discord")
time.sleep(10)
retries += 1
connect_loop(retries)
else:
update_loop()
print("Started Adobe RPC")
def update_loop():
start_time = int(time.time())
try:
while True:
rpc_data = handler.get_rpc_update()
rich_presence.update(state=rpc_data['state'],
small_image=rpc_data['small_image'],
large_image=rpc_data['large_image'],
large_text=rpc_data['large_text'],
small_text=rpc_data['small_text'],
details=rpc_data['details'],
start=start_time)
time.sleep(15)
except:
rich_presence.clear()
print("Run Adobe/Discord app")
time.sleep(5)
update_loop()
try:
connect_loop()
except KeyboardInterrupt:
print("Stopped Adobe RPC")