Browse Source

я крутой

huy
gsd 2 years ago
parent
commit
de8f05f1d8
  1. 3
      other_ext/stats_loader.py
  2. 6
      other_ext/stats_presence.py

3
other_ext/stats_loader.py

@ -7,7 +7,7 @@ class Extension:
def __init__(self, core): def __init__(self, core):
self.core = core self.core = core
async def task(self, timeout = 60): async def task(self, timeout = 15):
await self.core.wait_until_ready() await self.core.wait_until_ready()
while True: while True:
await self.updater() await self.updater()
@ -15,7 +15,6 @@ class Extension:
async def updater(self): async def updater(self):
try: try:
print("Load stats from backend")
self.core.stats = await self.core.GetStats() self.core.stats = await self.core.GetStats()
except: except:
traceback.print_exc() traceback.print_exc()

6
other_ext/stats_presence.py

@ -9,7 +9,7 @@ class Extension:
def __init__(self, core): def __init__(self, core):
self.core = core self.core = core
async def task(self, timeout = 3): async def task(self, timeout = 5):
await self.core.wait_until_ready() await self.core.wait_until_ready()
while True: while True:
await self.updater() await self.updater()
@ -28,7 +28,9 @@ class Extension:
server = list(self.core.stats['servers'].values())[self.show_stats_prev] server = list(self.core.stats['servers'].values())[self.show_stats_prev]
addr = server['address'].split(":") addr = server['address'].split(":")
act = discord.Streaming(name = f"{server['name']} - {server['player_count']}", url=f"https://{addr[0]}/connect/{addr[1]}") #act = discord.Streaming(name = f"{server['name']} - {server['player_count']}", url=f"https://{addr[0]}/connect/{addr[1]}")
# https://stackoverflow.com/a/59126629
act = discord.Activity(type=discord.ActivityType.watching, name = f"{server['name']} - {server['player_count']}")
await self.core.change_presence(activity=act) await self.core.change_presence(activity=act)
except: except:
traceback.print_exc() traceback.print_exc()
Loading…
Cancel
Save