On branch DiscordProfile

Initial commit
This commit is contained in:
EG
2026-07-01 15:15:07 +03:00
commit d4bf750c9e
3125 changed files with 601334 additions and 0 deletions
View File
Binary file not shown.
Binary file not shown.
+208
View File
@@ -0,0 +1,208 @@
import os
import discord
from discord.ext import commands, tasks
from services.profile_manager import set_value
from services.time_service import update_time
from services.discord_sync import sync
from dotenv import load_dotenv
load_dotenv()
TOKEN = os.getenv("TOKEN")
intents = discord.Intents.default()
bot = commands.Bot(
command_prefix="!",
intents=intents
)
@bot.event
async def on_ready():
print(
"Bot online",
bot.user,
flush=True
)
if not clock.is_running():
clock.start()
@tasks.loop(minutes=1)
async def clock():
update_time()
try:
result = sync()
if result:
print(
"AUTO SYNC:",
result.status_code,
flush=True
)
else:
print(
"AUTO SYNC: no response",
flush=True
)
except Exception as e:
print(
"SYNC ERROR",
e,
flush=True
)
@bot.slash_command(
name="ping",
description="Проверка бота"
)
async def ping(ctx):
await ctx.respond(
"Pong!"
)
@bot.slash_command(
name="refresh",
description="Принудительное обновление"
)
async def refresh(ctx):
update_time()
result = sync()
if result:
await ctx.respond(
f"✅ Widget updated\nHTTP {result.status_code}"
)
else:
await ctx.respond(
"❌ Sync failed"
)
@bot.slash_command(
name="sub2",
description="Изменить второй текст"
)
async def sub2(
ctx,
text: str
):
set_value(
"sub2",
text
)
sync()
await ctx.respond(
"✅ sub2 обновлён"
)
@bot.slash_command(
name="sub3",
description="Изменить третий текст"
)
async def sub3(
ctx,
text: str
):
set_value(
"sub3",
text
)
sync()
await ctx.respond(
"✅ sub3 обновлён"
)
@bot.slash_command(
name="subi2",
description="Иконка второго слота"
)
async def subi2(
ctx,
url: str
):
set_value(
"subi2",
url
)
sync()
await ctx.respond(
"🖼️ subi2 обновлена"
)
@bot.slash_command(
name="subi3",
description="Иконка третьего слота"
)
async def subi3(
ctx,
url: str
):
set_value(
"subi3",
url
)
sync()
await ctx.respond(
"🖼️ subi3 обновлена"
)
bot.run(TOKEN)
+10
View File
@@ -0,0 +1,10 @@
import aiohttp
import asyncio
async def main():
async with aiohttp.ClientSession(trust_env=True) as session:
async with session.get("https://discord.com/api/v10") as r:
print(r.status)
print(await r.text())
asyncio.run(main())