News: Use KSP_URL as a constant
And don't have it copied everywhere
This commit is contained in:
parent
7e9e479e06
commit
52116229e6
1 changed files with 3 additions and 3 deletions
|
@ -6,7 +6,7 @@ from markdownify import markdownify
|
||||||
import re
|
import re
|
||||||
from bs4 import BeautifulSoup
|
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
|
import hrochobot.utils.data as data
|
||||||
|
|
||||||
NEWS_JSON = "news"
|
NEWS_JSON = "news"
|
||||||
|
@ -43,7 +43,7 @@ def format_entry(entry, author=None):
|
||||||
if author:
|
if author:
|
||||||
embed.set_author(name=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)
|
date = datetime.fromisoformat(entry.published)
|
||||||
embed.set_footer(text=date.strftime("%-d. %-m. %Y"))
|
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"])
|
channel = get(guild.channels, id=news_json["news_channel"])
|
||||||
feed = await ksp_feed()
|
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:
|
if len(entries_with_id) == 0:
|
||||||
return f"Entry with id ``{entry_id}`` not found."
|
return f"Entry with id ``{entry_id}`` not found."
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue