Browse Source

подозрение на кал

huy
gsd 2 years ago
parent
commit
00f3b1d8c0
  1. 8
      other_ext/stats_loader.py
  2. 27
      other_ext/stats_presence.py

8
other_ext/stats_loader.py

@ -1,6 +1,12 @@
from discord.ext import tasks
import traceback
class Extension:
def __init__(self, core):
@tasks.loop(seconds=60.0)
async def stats_loader(core):
core.stats = await core.GetStats()
try:
print("Load stats from backend")
core.stats = await core.GetStats()
except:
traceback.print_exc()

27
other_ext/stats_presence.py

@ -1,20 +1,25 @@
from discord.ext import tasks
import discord
import traceback
class Extension:
show_stats_prev = 0
def __init__(self, core):
@tasks.loop(seconds=3)
async def show_stats(core):
if not core.stats['servers'].items():
print("Stats not be loaded")
return
try:
server = core.stats['servers'].items()[self.show_stats_prev]
self.show_stats_prev += 1
except:
self.show_stats_prev = 0
server = core.stats['servers'].items()[self.show_stats_prev]
if not core.stats['servers'].items():
print("Stats not be loaded")
return
try:
server = core.stats['servers'].items()[self.show_stats_prev]
self.show_stats_prev += 1
except:
self.show_stats_prev = 0
server = core.stats['servers'].items()[self.show_stats_prev]
addr = server['address'].split(":")
act = discord.Streaming(name = f"{server['name']} - {server['player_count']}", url=f"https://{addr[0]}/connect/{addr[1]}")
await core.change_presence(activity=act)
addr = server['address'].split(":")
act = discord.Streaming(name = f"{server['name']} - {server['player_count']}", url=f"https://{addr[0]}/connect/{addr[1]}")
await core.change_presence(activity=act)
except:
traceback.print_exc()
Loading…
Cancel
Save