Load the words into flash cards
This commit is contained in:
parent
961cf12934
commit
bdb969da5b
|
@ -6,7 +6,7 @@ from utils import (
|
||||||
request,
|
request,
|
||||||
Pages,
|
Pages,
|
||||||
CannotPaginate,
|
CannotPaginate,
|
||||||
chunks,
|
FlashCard,
|
||||||
FlashCardDisplay,
|
FlashCardDisplay,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -31,18 +31,28 @@ class Japanese(commands.Cog):
|
||||||
self.verbs = verbs
|
self.verbs = verbs
|
||||||
|
|
||||||
# Load the JLPT vocab
|
# Load the JLPT vocab
|
||||||
with open("utils/japanese_vocabulary_n2.json") as f:
|
for i in range(2, 6):
|
||||||
n2 = json.load(f)
|
with open(f"utils/japanese_vocabulary_n{i}.json") as f:
|
||||||
self.n2_packs = list(chunks(n2, 50))
|
n = json.load(f)
|
||||||
with open("utils/japanese_vocabulary_n3.json") as f:
|
count = 0
|
||||||
n3 = json.load(f)
|
# Will be a list of flash card packs
|
||||||
self.n3_packs = list(chunks(n3, 50))
|
packs = []
|
||||||
with open("utils/japanese_vocabulary_n4.json") as f:
|
# A list of flash cards
|
||||||
n4 = json.load(f)
|
pack = []
|
||||||
self.n4_packs = list(chunks(n4, 50))
|
|
||||||
with open("utils/japanese_vocabulary_n5.json") as f:
|
for card in n:
|
||||||
n5 = json.load(f)
|
# Add the card to the pack
|
||||||
self.n5_packs = list(chunks(n5, 50))
|
pack.append(FlashCard(card["vocabulary"], None, card["meaning"]))
|
||||||
|
count += 1
|
||||||
|
|
||||||
|
# Limit each pack to 50 cards
|
||||||
|
if count == 50:
|
||||||
|
count = 0
|
||||||
|
packs.append(pack.copy())
|
||||||
|
pack = []
|
||||||
|
|
||||||
|
# Now that the loading is done, set it
|
||||||
|
setattr(self, f"n{i}_packs", packs)
|
||||||
|
|
||||||
@commands.command(aliases=["活用", "かつよう", "katsuyou"])
|
@commands.command(aliases=["活用", "かつよう", "katsuyou"])
|
||||||
@checks.can_run(send_messages=True)
|
@checks.can_run(send_messages=True)
|
||||||
|
@ -147,7 +157,7 @@ query ($name: String) {
|
||||||
return await ctx.send("JLPT level options are n2, n3, n4, or n5")
|
return await ctx.send("JLPT level options are n2, n3, n4, or n5")
|
||||||
packs = getattr(self, f"{level}_packs")
|
packs = getattr(self, f"{level}_packs")
|
||||||
if pack > len(packs) or pack < 1:
|
if pack > len(packs) or pack < 1:
|
||||||
return await ctx.send(f"The JLPT {level} has {len(packs)} available")
|
return await ctx.send(f"The JLPT {level} has {len(packs)} packs available")
|
||||||
|
|
||||||
pack = packs[pack - 1]
|
pack = packs[pack - 1]
|
||||||
await FlashCardDisplay(pack).start(ctx, wait=True)
|
await FlashCardDisplay(pack).start(ctx, wait=True)
|
||||||
|
|
|
@ -4,4 +4,4 @@ from .config import *
|
||||||
from .utilities import *
|
from .utilities import *
|
||||||
from .paginator import Pages, CannotPaginate, HelpPaginator
|
from .paginator import Pages, CannotPaginate, HelpPaginator
|
||||||
from .database import DB, Cache
|
from .database import DB, Cache
|
||||||
from .flash_card import FlashCardDisplay
|
from .flash_card import FlashCardDisplay, FlashCard
|
Loading…
Reference in a new issue