How to use the pypresence.Presence 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 valknight / Splatnet2-Rich-Presence / discord_rich_presence.py View on Github external
def main():
    logger.info("Checking for updates...")
    os.system("git pull")
    logger.info(
        "If updates were done, restart this script by using CTRL-C to terminate it, and re run it.")

    # Make connection to Discord
    try:
        RPC = Presence(client_id)  # Initialize the Presence class
        RPC.connect()  # Start the handshake loop
    except pypresence.exceptions.InvalidPipe:
        logger.error(
            "Could not connect to the discord pipe. Please ensure it's running.")
        exit(1)
    except FileNotFoundError:
        logger.error(
            "Could not connect to the discord pipe. Please ensure it's running.")
        exit(1)

    # Load our current config
    config = nso_functions.get_config_file()
    logger.info("Check discord!")

    # Get friend code from config, and add config option if does not exist
    try:
github vincent-coding / DarkU / Main.py View on Github external
except:
    sys.exit(color.red + "An error occurred while importing TKinter. Please contact me as soon as possible.")

try:
    from tcpgecko import TCPGecko
    import tkinter.messagebox
except:
    sys.exit(color.red + "An error occurred with the import of pyGecko. Please contact me as soon as possible.")

try:
    from pypresence import Presence
except:
    sys.exit(color.red + "An error occurred while importing PyPresence. Please contact me as soon as possible.")

try:
    RPC = Presence(client_id)
    RPC.connect()
    RPC.update(state="Created by VCoding", details="Uses DarkU " + version, start=calendar.timegm(time.gmtime()), end=None, large_image="icons", large_text="DarkU " + version, small_image="copy", small_text="Created by VCoding", party_id=None, party_size=None)
except:
    print("")

def interface554():
    def saveip():
        saveipvalue = wiiuip.get()
        with open("ip.darku", "w") as ipconfig:
            ipconfig.write("ip:"+saveipvalue)
            tkinter.messagebox.showinfo("DarkU - "+version, "The ip has been saved!")
    
    def inject554():
        ip = wiiuip.get()
        colors = listecouleur.get()
        if ip != "":
github the-fancy-corporation / The-PyOS-Project / main.py View on Github external
loadPrcFileData('','window-title The PyOS Project')
loadPrcFileData('','load-display pandagl')
#loadPrcFileData('','basic-shaders-only #f') # is that useful? # obviously not
loadPrcFileData('', 'textures-power-2 none')
# Antialiasing
loadPrcFileData('','framebuffer-multisample 1')
loadPrcFileData('','multisamples 2') 

SKYBOX='sky'
BLUR=False # debug
MAINDIR=Filename.fromOsSpecific(os.getcwd())

# discord stuff -------------------------------
try:
    client_id = '591299679409668098' #bot id 
    RPC = Presence(client_id)
    RPC.connect()
    log=RPC.update(state="Version: 0.11", details="In the menus",large_image="logo",small_image=None)
    print('[Pypresence module]: connection to discord RPC successful, log data follows')
    print('[Pypresence module]:\n')
    print(log)
except:
    print('[WARNING]: discord RPC connection failed, proceeding anyway')
# discord presence is now active -------


class state(DirectObject):
    def __init__(self):
        super().__init__()
        self.root_node=NodePath('State Root')
        self.root_node.reparentTo(base.render)
        return None
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 smokes / adobe-rpc / rpc.py View on Github external
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()
github qwertyquerty / pypresence / examples / rich-presence-images.py View on Github external
from pypresence import Presence
import time

"""
You need to upload your image(s) here:
https://discordapp.com/developers/applications//rich-presence/assets
"""

client_id = "64567352374564"  # Enter your Application ID here.
RPC = Presence(client_id=client_id)
RPC.connect()

# Make sure you are using the same name that you used when uploading the image
RPC.update(large_image="big-image", large_text="Large Text Here!",
            small_image="small-image", small_text="Small Text Here!")

while 1:
    time.sleep(15) #Can only update presence every 15 seconds
github xKynn / PathOfExileRPC / poeRPC.py View on Github external
def __init__(self, loop, account_name, cookies, logger):
        self.rpc = Presence(CLIENT_ID, pipe=0, loop=loop)
        self.cookies = cookies
        self.log_path = None
        self.on = True
        self.loop = loop
        self.logger = logger
        self.last_location = None
        self.last_latest_message = ""
        self.last_event = LogEvents.LOGOUT
        self.afk = False
        self.dnd = False
        self.afk_message = ""
        self.dnd_message = ""
        self.account_name = account_name
        self.current_rpc = {}
        self.locations = {}
        self.quit = False
github the-fancy-corporation / The-PyOS-Project / main_alpha.py View on Github external
loadPrcFileData('','window-title PyOS')
loadPrcFileData('','load-display pandagl')
#loadPrcFileData('','basic-shaders-only #f') # is that useful? # obviously not
loadPrcFileData('', 'textures-power-2 none')
# Antialiasing
loadPrcFileData('','framebuffer-multisample 1')
loadPrcFileData('','multisamples 2') 

SKYBOX='sky'
BLUR=False # debug
MAINDIR=Filename.fromOsSpecific(os.getcwd())

# discord stuff -------------------------------
try:
    client_id = '591299679409668098' #bot id 
    RPC = Presence(client_id)
    RPC.connect()
    log=RPC.update(state="Version: 0.11", details="Playing Sandbox mode",large_image="logo",small_image=None)
    print('[Pypresence module]: connection to discord RPC successful, log data follows')
    print('[Pypresence module]:\n')
    print(log)
except:
    print('[WARNING]: discord RPC connection failed, proceeding anyway')
# discord presence is now active -------


class state(DirectObject):
    def __init__(self):
        super().__init__()
        self.root_node=NodePath('State Root')
        self.root_node.reparentTo(base.render)
        return None
github qwertyquerty / pypresence / examples / rich-presence-loop.py View on Github external
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