Add config file, dropdown for webhooks, and sends stuff to Discord

This commit is contained in:
Joakim Hellsén 2022-12-02 16:47:47 +01:00
commit 400b72dbf4
No known key found for this signature in database
GPG key ID: 01FD861E3DAC09AC
11 changed files with 326 additions and 185 deletions

View file

@ -1,26 +0,0 @@
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}")