-
Notifications
You must be signed in to change notification settings - Fork 16
/
eggs.py
44 lines (31 loc) · 837 Bytes
/
eggs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""
A polite little Discord bot that can send out a quote each day.
`eggs.py` handles the eggs.
"""
# import logging
# import random
import tomllib
from pathlib import Path
from typing import Any, NamedTuple
# import requests
import tomli_w
LOCAL_DIR = Path(__file__).parent.resolve()
EGGS = LOCAL_DIR / "eggs.toml"
"Eggs, of the Easter variety."
class Egg(NamedTuple):
"""Eggs, of the Easter variety"""
quote_id: str
quote_num: int
notes: str | None = None
def egg_hunting() -> dict[str, Egg]:
"""
Goes Egg hunting.
:returns: A basket of sorted Eggs.
:rtype: dict[str, Egg]
"""
raw_eggs = tomllib.loads(EGGS.read_text(encoding="utf8"))
# There is a better way to do this.. it sucks!
eggs = {}
for egg in raw_eggs:
eggs[egg] = Egg(**raw_eggs[egg])
return eggs