How to use the pypresence.Activity function in pypresence

To help you get started, we’ve selected a few pypresence examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github qwertyquerty / pypresence / examples / activity-cpu-usage.py View on Github external
from pypresence import Presence, Activity
import time
import psutil


client_id = '532533523424234'  # Fake ID, put your real one here

RPC = Presence(client_id)  # Initialize the client class
RPC.connect() # Start the handshake loop
ac = Activity(RPC) # Make the activity

ac.start = int(time.time())


print(ac.start)
while True:  # The presence will stay on as long as the program is running
    cpu_per = round(psutil.cpu_percent(),1) # Get CPU Usage
    mem_per = round(psutil.virtual_memory().percent,1) #Get Mem Usage

    ac.details = "RAM: {}%".format(mem_per) # Setting attrs of an activity will auto update the presence
    ac.state = "CPU: {}%".format(cpu_per)

    time.sleep(15) # Can only update rich presence every 15 seconds
github Browthon / Browthon-Reborn / browthon / Addons / discord / discord.py View on Github external
def run(self):
        self.rpc.connect()
        ac = Activity(self.rpc, large_image="logo", large_text="Browthon",
                      small_image="logo", small_text=self.main.version,
                      details="Par LavaPower", state="Navigateur web en Python")
        ac.start = int(time.time())
        while self.addon.launch:
            pass
        self.rpc.close()