Remove Typer and use Fastapi instead

This commit is contained in:
2022-12-01 21:11:44 +01:00
parent 38b91b9084
commit 3bec59cdb6
9 changed files with 960 additions and 288 deletions

View File

@ -0,0 +1,26 @@
import sys
from contextlib import closing
from reader import make_reader
from discord_rss_bot.discord_rss_bot import db_file_str
def webhook_get() -> None:
"""Get the webhook url"""
# TODO: Add name to output
with closing(make_reader(db_file_str)) as reader:
try:
webhook_url = reader.get_tag((), "webhook")
print(f"Webhook: {webhook_url}")
except Exception as e:
print("No webhook was found. Use `webhook add` to add one.")
print(f"Error: {e}\nPlease report this error to the developer.")
sys.exit()
def webhook_add(webhook_url: str) -> None:
"""Add a webhook to the database"""
with closing(make_reader(db_file_str)) as reader:
reader.set_tag((), "webhook", webhook_url)
print(f"Webhook set to {webhook_url}")