Réparation de la citation de l'éphéméride

This commit is contained in:
Simon Junod
2023-08-07 21:18:20 +02:00
parent d5b4bb4c87
commit 22130635b4
4 changed files with 509 additions and 414 deletions

View File

@@ -12,10 +12,13 @@ from .saints import SAINTS
def citation(): def citation():
try: try:
ts = datetime.now().strftime("%s") ts = datetime.now().strftime("%s")
req = requests.get(f"https://fr.wikiquote.org/wiki/Wikiquote:Accueil?r={ts}") req = requests.get("http://evene.lefigaro.fr/citations/citation-jour.php")
soup = bs(req.text, features="html.parser") soup = bs(req.text, features="html.parser")
citation = soup.find(lambda tag:tag.name=="i" and "Lumière sur" in tag.text).parent.parent.parent.findAll("div")[1].text.strip() bloc = soup.find("aside", {"class": "figsco__daily__citation__sidebar"})
return f"*{citation}*" citation = bloc.find("div", {"class":"figsco__quote__text"}).text.strip()
auteur = re.sub(r"/.*", "", bloc.find("div", {"class":"figsco__quote__from"}).text.strip()[3:]).strip()
return f"*{citation}*\n\n{auteur}"
except Exception: except Exception:
return "Impossible de trouver la citation du jour. Bouuuh !" return "Impossible de trouver la citation du jour. Bouuuh !"

892
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -2,18 +2,17 @@
name = "cambot" name = "cambot"
version = "0.1.0" version = "0.1.0"
description = "" description = ""
authors = ["Simon Junod <sj@simonjunod.ch>"] authors = ["Simon Junod <simon.junod@gammadia.ch>"]
readme = "README.md"
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.8" python = "^3.10"
unidecode = "^1.1.1" unidecode = "^1.3.6"
requests = "^2.24.0" requests = "^2.31.0"
bs4 = "^0.0.1" bs4 = "^0.0.1"
pip = "^22.0.4" nextcord = "^2.5.0"
nextcord = "^2.0.0-alpha.10"
[tool.poetry.dev-dependencies]
[build-system] [build-system]
requires = ["poetry>=0.12"] requires = ["poetry-core"]
build-backend = "poetry.masonry.api" build-backend = "poetry.core.masonry.api"

5
run.py
View File

@@ -82,6 +82,11 @@ async def on_message(message):
channel_id = int(regex.group(1)) channel_id = int(regex.group(1))
await wordle_games[channel_id].reset() await wordle_games[channel_id].reset()
if regex := re.search(r"^ephemeris$", content_lowercase):
embed = ephemeris.digest()
for channel_id in EPHEMERIS_CHANNEL_IDS:
await bot.get_channel(channel_id).send(embed=embed)
# Codenames whispers # Codenames whispers
if len(games_entered) == 1: if len(games_entered) == 1:
await codenames.process_whisper(games_entered[0], message) await codenames.process_whisper(games_entered[0], message)