Last active
July 10, 2023 00:58
-
-
Save dooderstem/d11a682ada9b5d6805e1465fd460cf42 to your computer and use it in GitHub Desktop.
pypresence
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://pypi.org/project/pypresence/ | |
# pip install pypresence | |
# Only Python versions 3.8 and above are supported. | |
from pypresence import Presence | |
import time | |
client_id = '64567352374564' # Fake ID, put your real one here | |
RPC = Presence(client_id) # Initialize the client class | |
RPC.connect() # Start the handshake loop | |
print(RPC.update(state="Lookie Lookie", details="A test of qwertyquerty's Python Discord RPC wrapper, pypresence!")) # Set the presence | |
while True: # The presence will stay on as long as the program is running | |
time.sleep(15) # Can only update rich presence every 15 seconds |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://pypi.org/project/pypresence/ | |
# pip install pypresence | |
# Only Python versions 3.8 and above are supported. | |
import psutil | |
from pypresence import Presence | |
import time | |
client_id = '64567352374564' # Fake ID, put your real one here | |
RPC = Presence(client_id,pipe=0) # Initialize the client class | |
RPC.connect() # Start the handshake loop | |
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 = psutil.virtual_memory() | |
mem_per = round(psutil.virtual_memory().percent,1) | |
print(RPC.update(details="RAM: "+str(mem_per)+"%", state="CPU: "+str(cpu_per)+"%")) # Set the presence | |
time.sleep(15) # Can only update rich presence every 15 seconds |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://pypi.org/project/pypresence/ | |
# pip install pypresence | |
# Only Python versions 3.8 and above are supported. | |
from pypresence import Presence | |
import time | |
import random | |
client_id = '64567352374564' # Put your Client ID here, this is a fake ID | |
RPC = Presence(client_id) # Initialize the Presence class | |
RPC.connect() # Start the handshake loop | |
quotes = [ | |
"If you can dream it, you can achieve it.", | |
"Either write something worth reading or do something worth writing.", | |
"You become what you believe.", | |
"Fall seven times and stand up eight.", | |
"The best revenge is massive success.", | |
"Eighty percent of success is showing up.", | |
"Life is what happens to you while you’re busy making other plans.", | |
"Strive not to be a success, but rather to be of value.", | |
"The best time to plant a tree was 20 years ago. The second best time is now.", | |
"Everything you’ve ever wanted is on the other side of fear." | |
] # The quotes to choose from | |
while True: # The presence will stay on as long as the program is running | |
RPC.update(details="Famous Quote:", state=random.choice(quotes)) #Set the presence, picking a random quote | |
time.sleep(60) #Wait a wee bit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment