1
0
mirror of https://gitee.com/sui-feng-cb/AzurLaneAutoScript1 synced 2026-03-17 05:15:25 +08:00

Opt: Refactor discord rpc

This commit is contained in:
18870
2022-06-03 23:00:54 +08:00
parent 5fa62d8144
commit 3e91ca7fcc
3 changed files with 18 additions and 20 deletions

View File

@@ -1,30 +1,22 @@
import asyncio
import time
from multiprocessing import Process
from pypresence import Presence
from pypresence import AioPresence
process: Process = None
RPC = AioPresence("929437173764223057")
def run():
APPLICATION_ID = "929437173764223057"
RPC = Presence(APPLICATION_ID)
RPC.connect()
RPC.update(state="Alas is playing Azurlane", start=time.time(), large_image="alas")
async def run():
await RPC.connect()
await RPC.update(state="Alas is playing Azurlane", start=time.time(), large_image="alas")
def init_discord_rpc():
global process
if process is None:
process = Process(target=run)
process.start()
asyncio.create_task(run())
def close_discord_rpc():
global process
if process is not None:
process.terminate()
process = None
RPC.close()
if __name__ == "__main__":