Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/SuperAnt220/antbot
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperAnt220 committed Sep 7, 2024
2 parents d4173ba + ea13fb5 commit f7cac02
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
29 changes: 15 additions & 14 deletions cogs/minecraft/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,25 @@
files = {}
latest_version = ""

@tasks.loop(minutes=3)
async def update_files_list():
global latest_version, files
if (newer_version:=db.find_one({"_id": "latest_known_snapshot"})["_"]) != latest_version:
latest_version = newer_version
async with ClientSession(headers=GITHUB_HEADERS) as session:
for tree_name in ("data", "assets"):
async with session.get(f"https://api.github.com/repos/misode/mcmeta/git/trees/{tree_name}?recursive=1",
headers={"User-Agent": "AntBot discord bot"}) as response:
tree = await response.json()
tree = tree.get("tree", [])
files.update({"/".join(item["path"].split("/")[-2:]): item["path"] for item in tree if item["type"] == "blob"})
files.pop(".gitattributes")


class FileCommand(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.update_files_list.start()

@tasks.loop(minutes=6)
async def update_files_list(self):
global latest_version, files
if (newer_version:=db.find_one({"_id": "latest_known_snapshot"})["_"]) != latest_version:
latest_version = newer_version
async with ClientSession(headers=GITHUB_HEADERS) as session:
for tree_name in ("data", "assets"):
async with session.get(f"https://api.github.com/repos/misode/mcmeta/git/trees/{tree_name}?recursive=1",
headers={"User-Agent": "AntBot discord bot"}) as response:
tree = await response.json()
tree = tree.get("tree", [])
files.update({"/".join(item["path"].split("/")[-2:]): item["path"] for item in tree if item["type"] == "blob"})
files.pop(".gitattributes")

@commands.hybrid_command(aliases=["f", "asset", "mcasset", "файл", "ашду", "ассет", "эссет", "мсассет", "мсэссэт","фыыуе","ьсфыыуе"],
description="Скидывает файл с ванильного датапака/ресурспака.",
Expand Down
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
discord.py>=2.4.0
pymongo
python-dotenv
Levenshtein
pillow

0 comments on commit f7cac02

Please sign in to comment.