Browse Source

News: Use KSP_URL as a constant

And don't have it copied everywhere
mail
Daniel Skýpala 1 year ago
parent
commit
52116229e6
  1. 6
      hrochobot/cogs/news.py

6
hrochobot/cogs/news.py

@ -6,7 +6,7 @@ from markdownify import markdownify
import re
from bs4 import BeautifulSoup
from hrochobot.utils.ksp_utils import ksp_feed
from hrochobot.utils.ksp_utils import ksp_feed, KSP_URL
import hrochobot.utils.data as data
NEWS_JSON = "news"
@ -43,7 +43,7 @@ def format_entry(entry, author=None):
if author:
embed.set_author(name=author)
embed.set_thumbnail(url="https://ksp.mff.cuni.cz/img/hippo_head.png")
embed.set_thumbnail(url=f"{KSP_URL}/img/hippo_head.png")
date = datetime.fromisoformat(entry.published)
embed.set_footer(text=date.strftime("%-d. %-m. %Y"))
@ -57,7 +57,7 @@ async def post_news(bot, guild, entry_id):
channel = get(guild.channels, id=news_json["news_channel"])
feed = await ksp_feed()
entries_with_id = list(filter(lambda e: e.id == f"https://ksp.mff.cuni.cz/{entry_id}", feed.entries))
entries_with_id = list(filter(lambda e: e.id == f"{KSP_URL}/{entry_id}", feed.entries))
if len(entries_with_id) == 0:
return f"Entry with id ``{entry_id}`` not found."

Loading…
Cancel
Save