def update_presence(app_id, values): global RPC global previous_id if app_id != previous_id: if isinstance(RPC, pypresence.Presence): RPC.close() RPC = pypresence.Presence(app_id) RPC.connect() previous_id = app_id party_size = None if values['party_size'] is not None and values['party_max'] is not None: party_size = [values['party_size'], values['party_max']] RPC.update(state=values['state'], details=values['details'], start=values['start'], end=values['end'], large_image=values['large_image_key'], large_text=values['large_image_text'], small_image=values['small_image_text'], small_text=values['small_image_text'], party_size=party_size)
def __init__(self): super().__init__() try: self.currentInstance = os.listdir(config.MC_DIR + "/instances")[0] except: self.currentInstance = "" self.loggedIn = False # Tells the launcher if the user is logged in. utils.areYouThere(config.MC_DIR + "/instances") screen_resolution = app.desktop().screenGeometry() # Gets primary monitor resolution. self.title = config.NAME + " " + config.VER config.ICON = utils.loadImage("favicon.ico", self.currentInstance) self.setWindowIcon(QIcon(config.ICON)) config.LOGO = utils.loadImage("logo.png", self.currentInstance) config.BACKGROUND = utils.loadImage("background.png", self.currentInstance) config.BLOG_BACKGROUND = utils.getFile("blogbackground.png", self.currentInstance) config.BLOG = utils.getFile("blog.html", self.currentInstance) self.left = (screen_resolution.width() / 2) - 427 self.top = (screen_resolution.height() / 2) - 240 self.launcherConfig = utils.loadSettings(self) self.instanceConfig = utils.loadInstanceSettings(self, self.currentInstance) try: self.pres = pypresence.Presence("548208354196062228") # Go ahead and use this if you want, provided you are modifying the launcher. Not that I can really stop you. self.pres.connect() self.pres.update(details="In launcher", large_image="pymcllogo512", state="Selected modpack: " + self.currentInstance) except: self.pres = None self.checkAlive(threadingEvent) self.update = utils.checkOnline() self.initUI()
def start_drp(): rpc = pypresence.Presence(discord_client_id) rpc.connect() last_msg = "" while True: # The presence will stay on as long as the program is running try: msg = get_msg() if msg and last_msg != msg: print("Msg: " + msg) last_msg = msg data = parse_msg(msg) rpc.update(state=format_state(data), details=format_details(data), start=format_start(data), large_image=format_large_image(data), large_text=format_large_text(data), small_image=format_small_image(data), small_text=format_small_text(data), party_size=format_party_size(data)) logger.info("Successfully updated discord activity") except Exception: logger.exception("Exception in Main Loop") logger.exception("Exception: " + traceback.format_exc()) print("Exception in Main Loop") print("Exception: " + traceback.format_exc()) time.sleep(1)
def __init__(self, references: dict, loop): """ Initialize :param references: (dict) the references """ self.references = references try: self.rpc = pypresence.Presence(client_id="733376215737434204", loop=loop) self.rpc.connect() # Discord not open (or not installed) except pypresence.InvalidPipe: self.rpc = None self.last_server = None self.last_time = None self.partner_servers = { "hivebedrock.network": "The Hive", "inpvp.net": "Mineville", "mineplex.com": "Mineplex", "galaxite.net": "Galaxite", "lbsg.net": "Lifeboat", "cubecraft.net": "CubeCraft" } self.feature = None # For ui self.tk_vars = {} # Add to references self.references.update({"Discord": self}) Logger.log("Discord", add=True)
def __init__(self, client_id, on_error=None): self._presence = pypresence.Presence(client_id=client_id, handler=None) self._on_error = on_error self._is_connected = False self._error_count = 0
def updatepresence(irpc): try: if options['discord']: if not irpc: irpc = pypresence.Presence(CLIENTID) irpc.connect() args = { 'large_image': 'btecify1024', 'large_text': APPNAME } if player.song: args['details'] = f"{player.song.name} | {player.song.author}" if player.paused: args['state'] = "Paused" else: args['state'] = "Playing" args['start'] = int(player.getstart()) args['end'] = int(player.getend()) else: args['state'] = "Stopped" irpc.update(**args) return irpc elif not options['discord']: if irpc: irpc.close() return None except (pypresence.InvalidID, pypresence.InvalidPipe, RuntimeError, Exception) as e: print(e) print("Discord not found or presence failed.") return None
def __init__(self): super().__init__() self._presence_client = pypresence.Presence(DISCORD_CLIENT_ID) self.__connected = False self._game_client_running = False self._game_state = None
def __init__(self): logging.basicConfig(stream=sys.stdout, level=logging.INFO) self.logger = logging.getLogger(__name__) self.logger.info("Initializing.") self.bus = dbus.SessionBus() self.client = pypresence.Presence(CLIENT_ID) self.player = None self.prop_iface = None
def rpc(): rpc = pypresence.Presence(config['rpcid']['id']) rpc.connect() rpc.update(state=config['contect']['state'], details=config['contect']['details'], large_image=config['contect']['large_image'], large_text=config['contect']['large_text'], small_image=config['contect']['small_image'], small_text=config['contect']['small_text'])
def __init__(self): logging.basicConfig(stream=sys.stdout, level=logging.INFO) self.logger = logging.getLogger(__name__) print("[INFO] Starting...") self.bus = dbus.SessionBus() self.client = pypresence.Presence(APPLICATION_ID) self.player = None self.prop_iface = None
def __init__(self, client_id: int, large_image="large", print_status=True): try: self.RPC = pypresence.Presence(client_id, pipe=0) self.RPC.connect() self.large_image = large_image if print_status: print(f"Connected to discord client [{client_id}]") except ConnectionRefusedError: print("Failed to connect to discord, is the client open?") exit()
def presence(): try: fp = json.load(io.open('config.json', 'r', encoding='utf-8-sig')) except Exception as error: while True: a = input( '[WARN] Обнаружена ошибка в файле "config.json"!\nЖелаете загрузить (и сохранить в файл) конфигурацию по умолчанию? (Y-Да/N-Нет)\n> ' ) if a.lower() == 'y': fp = json.dump(_default, io.open('config.json', 'w', encoding='utf-8'), indent=2) time.sleep(1.0) return print( 'Готово. \nОтредактируйте конфиг и перезапустите приложение.' ) elif a.lower() == 'n': sys.exit(0) try: a = pypresence.Presence(fp['client_id'], pipe=0) a.connect() if fp['assets']['show_spectate_button'] == True: spec = fp['spectate_secret'] else: spec = None if fp['assets']['show_join_button'] == True: join = fp['join_secret'] else: join = None if fp['end'] == None: fp['end'] = None if fp['end'] == '$real': fp['end'] = time.time() if fp['start'] == None: fp['start'] = None if fp['start'] == '$real': fp['start'] = time.time() a.update(large_image=fp['assets']['large_icon'], large_text=fp['assets']['large_icon_text'], state=fp['state'], details=fp['details'], small_image=fp['assets']['small_icon'], small_text=fp['assets']['small_icon_text'], end=fp['end'], start=fp['start'], spectate=spec, join=join) except Exception as e: return print( 'Возникла ошибка в создании процесса Rich Presence. \nПроверьте правильность ввода данных.\n\nПодробности:\n{}' .format(e)) print('Rich Presence запущен!')
def definePresence(self, appId=None): if not appId: appId = self.config['appId'] self.closeRunningLoop() self.presence = None self.presence = pypresence.Presence(client_id=appId, loop=asyncio.new_event_loop()) self.presence.connect() if not self.updatePresenceState(): self.closeRunningLoop() self.presence = None
def presence(): global rpc global config global started global connected file = get_np() if file is not None: if not connected: rpc = pypresence.Presence(config["clientId"]) rpc.connect() connected = True started = calendar.timegm(datetime.utcnow().utctimetuple()) if file.startswith("*"): file = file[1:] name = file.split("\\")[-1] if not name.startswith("new ") and "." in name: extension = name.split(".")[-1] else: extension = None if config["fileSwitchResetsTimer"]: global old_file if "old_file" in globals() and old_file != file: started = calendar.timegm(datetime.utcnow().utctimetuple()) old_file = file try: if name.startswith("*new ") or name.startswith("new "): raise Exception size = os.path.getsize( file) if file[0] != "*" else os.path.getsize(file[1:]) if size <= 1024: size_text = str(size) + " " + config["bytes"] elif size < 1024 * 1024: size_text = float_format( size / 1024) + " " + config["kilobytes"] elif size < 1024 * 1024 * 1024: size_text = float_format( size / (1024 * 1024)) + " " + config["megabytes"] elif size < 1024 * 1024 * 1024: size_text = float_format( size / (1024 * 1024 * 1024)) + " " + config["gigabytes"] except: size_text = None rpc.update(details=config["details"].replace("{}", name), state=size_text, large_image=config["large_image"], small_image=config["small_image"].replace("{}", extension) if extension is not None else None, small_text=ext[extension] if extension is not None and extension in ext else None, start=started) elif connected: rpc.close() connected = False
def __init__(self): with open("settings.json", 'r') as file: settings = json.loads(file.read()) if settings['pypresence']: client_id = '605045493592227860' self.RPC = pypresence.Presence(client_id) self.RPC.connect() details = "In menu:" state = "Game launcher" self.RPC.update(details = details, state = state) self.main_loop()
def connect(self): """ Connects to a Discord Rich Presence session. """ if not self._connected: self._client = pypresence.Presence(self._client_id, pipe=self._pipe) try: self._client.connect() except pypresence.exceptions.InvalidPipe as e: ErrorHandler(e.args[0]) else: self._connected = True
def CreatePyPresenceConnection(): """ utilisé pour créer une connexion discord rich presence si votre application discord est ouverte :return: """ client_id = "686550339578495046" try: RPC = pypresence.Presence(client_id) RPC.connect() pypresenceEnabled = True return RPC except pypresence.exceptions.InvalidPipe: pypresenceEnabled = False
def update_status(self, state): if not self.display_status: return if self.RPC is None: try: self.RPC = pypresence.Presence( self.client_id) # Initialize the Presence client self.RPC.connect() # Start the handshake loop self.RPC.update(state=state) self.update_time = time.time() except: self.RPC = None elif self.update_time + 15 < time.time(): self.RPC.update(state=state) self.update_time = time.time()
def start_drp(): rpc = pypresence.Presence(discord_client_id) rpc.connect() last_msg = "" while True: # The presence will stay on as long as the program is running try: msg = get_msg() wow_proc = get_wow_process() if not msg and not wow_proc: rpc.clear() if not msg and wow_proc: rpc_update = { 'pid': wow_proc.pid, 'state': 'Main Menu', 'details': 'Selecting a character', 'start': int(wow_proc.create_time()), } rpc.update(**rpc_update) if msg and last_msg != msg: print("Msg: " + msg) data = parse_msg(msg) rpc_update = { 'state': format_state(data), 'details': format_details(data), 'start': format_start(data), 'large_image': format_large_image(data), 'large_text': format_large_text(data), 'small_image': format_small_image(data), 'small_text': format_small_text(data), 'party_size': format_party_size(data) } if wow_proc: rpc_update['pid'] = wow_proc.pid rpc.update(**rpc_update) if last_msg == "": sleep(3) rpc.update(**rpc_update) last_msg = msg logger.info("Successfully updated discord activity") except Exception: logger.exception("Exception in Main Loop") logger.exception("Exception: " + traceback.format_exc()) print("Exception in Main Loop") print("Exception: " + traceback.format_exc()) time.sleep(1)
def presence_menu(self): with open("settings.json", 'r') as file: settings = json.loads(file.read()) settings['pypresence'] = self.presence_var.get() self.presence = settings['pypresence'] with open("settings.json", 'w+') as file: file.write(json.dumps(settings, indent = 4)) if self.presence: if not hasattr(self, 'RPC'): client_id = '605045493592227860' self.RPC = pypresence.Presence(client_id) self.RPC.connect() details = "In menu:" state = "Game launcher" self.RPC.update(details = details, state = state) else: self.RPC.clear()
def __init__(self, config, status_callback=None): super().__init__() self.config = config self.status_callback = status_callback self.timeout_backoff = 0 self.last_player = None self.run = True self.assets = None try: self.presence = pypresence.Presence( self.config.preferences['rpc']['oauth_id']) self.presence.connect() except (pypresence.PyPresenceException, ConnectionRefusedError): MsgBoxes.warn( 'It appears that your Discord client is not accepting requests. \n' 'Please try restarting it and then run this program again.') sys.exit()
def start(self): print(f""" Groove Music DRP v{self.version} [0] - Start Automatic [Unstable] [1] - Start Manual [2] - Exit Select an option >> """) option = input() system('cls') if option not in ["0", "1", "2"]: print("Invalid option, try again!\n") self.start() elif option == "0" or option == "1": self.automatic = True if option == "0" else False self.RPC = pypresence.Presence(self.DRP_ID, pipe=0) self.RPC.connect() print(self.RPC.update()) self.main_process() elif option == "2": exit()
import psutil import pypresence def excepthook(_, error, __): if not isinstance(error, pypresence.InvalidID): sys.__excepthook__(type(error), error, error.__traceback__) sys.excepthook = excepthook # how many seconds to spend between updates DELAY = 3 client = pypresence.Presence('486029858158280716') while True: try: client.connect() except (ConnectionRefusedError, FileNotFoundError): time.sleep(DELAY) continue else: break def get_nano_processes(): user = getuser() try: return sorted(filter( lambda process: process.username() == user,
def connect(self): self.presence = discord.Presence(self.app_id) self.presence.connect()
aal("LOD", "If you ever need to debug something, please send this log to https://discord.gg/yTxrCGR.") try: open(".nocol", "r") ## If we can open .nocol, it must exist from Configs.color import nocolours as p ## Import the disabled colour scheme aal("INF", "Disable terminal color") ## Output info to log except: from Configs.color import colours as p ## Import the enabled colour scheme aal("INF", "Enable terminal color") ## Output info to log ## Connectig to application rpc = pypr.Presence(c.application_DID) rpc.connect() ## Def's for commands UwU def setStatus(silent,large,small,ltext,stext,details,state): ## This is default def for changing presence try: rpc.update(large_image=large,small_image=small,large_text=ltext,small_text=stext,details=details,state=state,start=int(time.time())) # Update presence aal("INF","Updated presence: " + str(silent) + ", " + str(large) + ", " + str(small) + ", " + str(ltext) + ", " + str(stext) + ", " + str(details) + ", " + str(state)) # Output presence to log if silent == 0: print(p.success + "Presence updated.") # Give success message except Exception as e: print(p.fail + "There was a problem updating your presence: " + str(e)) # Presence update failed, print error message aal("ERR","Couldn't update presence: " + str(e)) # Output error to log
def is_process_running(required_processes=[ "VALORANT-Win64-Shipping.exe", "RiotClientServices.exe" ]): processes = [] for proc in psutil.process_iter(): try: processes.append(proc.name()) except (PermissionError, AccessDenied): pass # some processes are higher than user-level and cannot have its attributes accessed for process in required_processes: if process in processes: return True return False # discord rpc implementation rpc, rpc_state = pypresence.Presence( client_id=str(config["client_id"])), None rpc_menu_default = { "large_image": "valorant-logo", "large_text": "VALORANT®" } rpc_gamemode_equivalents = config["rpc_gamemode_equivalents"] def rpc_update( **kwargs ): # only interacts with the RPC api if the requested state is different than its current state global rpc, rpc_state if kwargs != rpc_state: print(kwargs) rpc.update(**kwargs) rpc_state = kwargs
def __init__(self, token: str, oauth: str = None): self.rpc = pypresence.Presence(token) self.rpc.connect()
print( "MPRIS-compatible Discord Rich Presence by marios8543\nhttps://github.com/marios8543/MPRIS-Discord" ) from mpris2 import get_players_uri, Player from dbus.mainloop.glib import DBusGMainLoop import dbus import pypresence from time import sleep dbus_loop = DBusGMainLoop() bus = dbus.SystemBus(mainloop=dbus_loop) rpc = pypresence.Presence("508273804720734209") def rpc_connect(): while True: try: rpc.connect() except Exception: print("Discord RPC failed to connect. Retrying after 5 seconds") sleep(5) else: break rpc_connect() player_assets = ['amarok', 'kodi', 'smplayer', 'spotify'] player_statuses = ['playing', 'paused']
elif (media_type == "episode"): title = f'{metadata.grandparentTitle} - {metadata.title}' subtitle = f'S{metadata.parentIndex} · E{metadata.index}' RPC.update(state=timestamp, details=title, large_image="plex", large_text=activity, small_image="plex", small_text=activity) if __name__ == "__main__": client_id = credents.CONFIG["client_id"] PLEX_USERNAME = credents.CONFIG["PLEX_USERNAME"] PLEX_PASSWORD = credents.CONFIG["PLEX_PASSWORD"] PLEX_SERVER = credents.CONFIG["PLEX_SERVER"] RPC = pypresence.Presence(client_id) RPC.connect() account = MyPlexAccount(PLEX_USERNAME, PLEX_PASSWORD) plex = account.resource(PLEX_SERVER).connect() print(account) plex_admin = (account.email == plex.myPlexUsername or account.username == plex.myPlexUsername) plex.startAlertListener(process_alert) try: while True: time.sleep(3600) continue except KeyboardInterrupt: print("Exiting Discord RPC")
def main(): if platform.system() == 'Windows': system('title VanishSee') color_print( Fore.LIGHTRED_EX, "\n ██▒ █▓ ▄▄▄ ███▄ █ ██▓ ██████ ██░ ██ ██████ ▓█████ ▓█████ " ) color_print( Fore.LIGHTRED_EX, "▓██░ █▒▒████▄ ██ ▀█ █ ▓██▒▒██ ▒ ▓██░ ██▒▒██ ▒ ▓█ ▀ ▓█ ▀" ) color_print( Fore.LIGHTRED_EX, " ▓██ █▒░▒██ ▀█▄ ▓██ ▀█ ██▒▒██▒░ ▓██▄ ▒██▀▀██░░ ▓██▄ ▒███ ▒███" ) color_print( Fore.LIGHTRED_EX, " ▒██ █░░░██▄▄▄▄██ ▓██▒ ▐▌██▒░██░ ▒ ██▒░▓█ ░██ ▒ ██▒▒▓█ ▄ ▒▓█ ▄" ) color_print( Fore.LIGHTRED_EX, " ▒▀█░ ▓█ ▓██▒▒██░ ▓██░░██░▒██████▒▒░▓█▒░██▓▒██████▒▒░▒████▒░▒████▒" ) color_print( Fore.RED, " ░ ▐░ ▒▒ ▓▒█░░ ▒░ ▒ ▒ ░▓ ▒ ▒▓▒ ▒ ░ ▒ ░░▒░▒▒ ▒▓▒ ▒ ░░░ ▒░ ░░░ ▒░ ░" ) color_print( Fore.RED, " ░ ░░ ▒ ▒▒ ░░ ░░ ░ ▒░ ▒ ░░ ░▒ ░ ░ ▒ ░▒░ ░░ ░▒ ░ ░ ░ ░ ░ ░ ░ ░" ) color_print( Fore.RED, " ░░ ░ ▒ ░ ░ ░ ▒ ░░ ░ ░ ░ ░░ ░░ ░ ░ ░ ░" ) color_print( Fore.RED, " ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░" ) color_print( Fore.RED, " ░ " ) print(f"\nVanishSee v{__VERSION__}") color_print(Fore.LIGHTYELLOW_EX, f"by {__AUTHOR__[0]} aka {__AUTHOR__[1]}\n") with open('config.yml') as config_file: config = yaml.safe_load(config_file) rpc = pypresence.Presence(__CLIENT_ID__) if config['discord_rich_presence']: try: rpc.connect() rpc.update(large_image='ghost', large_text="VanishSee by workonfire#8262", small_image='gc2', small_text="GC2", details="Sprawdza osoby na /v") except pypresence.ServerError and pypresence.DiscordError and pypresence.PyPresenceException: config['discord_rich_presence'] = False if config['debug']: color_print(Fore.RED, "UWAGA: Tryb debugowania jest włączony.") nickname = input("Nick: ") password = input("Hasło (jeśli masz włączony autologin, zostaw puste): ") if password != '': color_print( Fore.RED, "UWAGA: PIN'y nie są jeszcze obsługiwane. Usuń PIN przed podaniem hasła." ) game_mode = input("Tryb (np. SkyBlock 1): ") if game_mode == 'wzium': color_print(Fore.LIGHTRED_EX, "▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄") color_print(Fore.LIGHTYELLOW_EX, "██ ███ █▄▄ ██▄██ ██ █ ▄▀▄ ██") color_print(Fore.LIGHTGREEN_EX, "██ █ █ █▀▄███ ▄█ ██ █ █▄█ ██") color_print(Fore.LIGHTBLUE_EX, "██▄▀▄▀▄█▄▄▄█▄▄▄██▄▄▄█▄███▄██") color_print(Fore.LIGHTMAGENTA_EX, "▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀") print("Nie no, tak serio.. to SkyBlock 1.") game_mode = 'SkyBlock 1' def extract_userlist(client_output: str) -> list: client_output = client_output.split("\n") for line in client_output: if "[MCC] PlayerList:" in line: return line.strip("[MCC] PlayerList: ").split(", ") def perform_exploit(nick: str, account_password: str, gamemode: str) -> str: color_print(Fore.GREEN, "\nDołączanie na serwer...") client = GC2Client(nick) start_time = time() color_print(Fore.GREEN, "Logowanie...", no_newline=True) sleep(config['wait_before_authenticating']) if account_password != '': client.authenticate(account_password) print(' [' + str(round(time() - start_time, 2)) + ' s]') start_time = time() color_print(Fore.GREEN, "Wchodzenie na tryb...", no_newline=True) sleep(config['wait_before_joining']) client.join(gamemode.upper()) print(' [' + str(round(time() - start_time, 2)) + ' s]') start_time = time() color_print(Fore.GREEN, "Sprawdzanie listy użytkowników...", no_newline=True) sleep(config['wait_before_checking_player_list']) client.send_input('/list') print(' [' + str(round(time() - start_time, 2)) + ' s]') start_time = time() color_print(Fore.GREEN, "Kończenie...", no_newline=True) sleep(config['wait_before_sending_output']) print(' [' + str(round(time() - start_time, 2)) + ' s]') return client.get_full_output() if config['discord_rich_presence']: rpc.update(large_image='ghost', small_image='gc2', small_text="GC2", details="Sprawdza osoby na /v", state="Tryb: " + game_mode) while True: output = perform_exploit(nickname, password, game_mode) userlist = extract_userlist(output) vanished_players = [] if config['debug']: print(output) if userlist is not None: print("\nLista wszystkich zalogowanych administratorów:") for user in userlist: if user in config['staff']: vanished_players.append(user) if vanished_players: for player in vanished_players: color_print(Fore.LIGHTYELLOW_EX, ">> ", no_newline=True) color_print(Fore.CYAN, player) else: color_print(Fore.CYAN, "Brak :(") print( "\nJeśli nie udało się pobrać listy administracji na vanishu, ", end='') color_print(Fore.LIGHTRED_EX, "spróbuj ponownie", no_newline=True) print(".") print("Upewnij się też, że w ogóle ktoś siedzi ukryty.") if platform.system() == 'Windows': system('title VanishSee') print("\nBy spróbować ponownie, naciśnij Enter.") input() elif "Failed to login to this server." in output: color_print( Fore.RED, f"\nNie udało się zalogować na konto {nickname}. Jeśli jesteś obecnie na" " GC2 - wyjdź.") print("Naciśnij Enter, by kontynuować.") input() else: color_print( Fore.RED, "\nNie udało się sprawdzić listy użytkowników. Ponawianie...") sleep(2)