Spaces:
Sleeping
Sleeping
File size: 1,473 Bytes
85d3b29 |
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 49 50 |
from pypresence import Presence
import datetime as dt
import time
class RichPresenceManager:
def __init__(self):
self.client_id = "1144714449563955302"
self.rpc = None
self.running = False
def start_presence(self):
if not self.running:
self.running = True
self.rpc = Presence(self.client_id)
try:
self.rpc.connect()
self.update_presence()
except KeyboardInterrupt as error:
print(error)
self.rpc = None
self.running = False
except Exception as e:
print(f"Error: Unable to connect to Rich Presence. {e}")
self.rpc = None
self.running = False
def update_presence(self):
if self.rpc:
self.rpc.update(
state="applio.org",
details="Ultimate voice cloning tool.",
buttons=[
{"label": "Home", "url": "https://applio.org"},
{"label": "Download", "url": "https://applio.org/download"},
],
large_image="logo",
large_text="Experimenting with applio",
start=dt.datetime.now().timestamp(),
)
def stop_presence(self):
self.running = False
if self.rpc:
self.rpc.close()
self.rpc = None
RPCManager = RichPresenceManager()
|