mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-18 10:21:30 +08:00
AlasGG
This commit is contained in:
24
module/webui/discord_presence.py
Normal file
24
module/webui/discord_presence.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import asyncio
|
||||
import time
|
||||
|
||||
from pypresence import AioPresence
|
||||
|
||||
RPC: AioPresence = None
|
||||
|
||||
|
||||
async def run():
|
||||
assert RPC is not None
|
||||
await RPC.connect()
|
||||
await RPC.update(state="Alas is playing Azurlane", start=time.time(), large_image="alas")
|
||||
|
||||
|
||||
def init_discord_rpc():
|
||||
global RPC
|
||||
RPC = AioPresence("929437173764223057")
|
||||
asyncio.create_task(run())
|
||||
|
||||
|
||||
def close_discord_rpc():
|
||||
if RPC:
|
||||
RPC.send_data(2, {'v': 1, 'client_id': RPC.client_id})
|
||||
RPC.sock_writer.close()
|
||||
Reference in New Issue
Block a user