From badaee2e70e7eb8e407ad59e4367df00d51ca2fd Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 11 Apr 2020 02:20:47 +0200 Subject: [PATCH] Add urls to some things --- poetry.lock | 8 ++++---- pyproject.toml | 2 +- royalpack/commands/matchmaking.py | 22 +++++++++++++--------- royalpack/commands/userinfo.py | 7 ++++--- royalpack/tables/diario.py | 2 +- 5 files changed, 23 insertions(+), 18 deletions(-) diff --git a/poetry.lock b/poetry.lock index fa875965..696d29c7 100644 --- a/poetry.lock +++ b/poetry.lock @@ -588,7 +588,7 @@ description = "A multipurpose bot and web framework" name = "royalnet" optional = false python-versions = ">=3.8,<4.0" -version = "5.7.4" +version = "5.7.5" [package.dependencies] dateparser = ">=0.7.2,<0.8.0" @@ -869,7 +869,7 @@ python-versions = "*" version = "2020.3.24" [metadata] -content-hash = "5ac785ed6a80e09159e8535a5ba5f53f8411c7e40185d2d06caf467e87c6936c" +content-hash = "06c91734690c9d27a1355db7d6de24bf0601896f7434c99558873f659e075c6a" python-versions = "^3.8" [metadata.files] @@ -1310,8 +1310,8 @@ riotwatcher = [ {file = "riotwatcher-2.7.1.tar.gz", hash = "sha256:5349271c7e00637b7619491a6070e66603705db60558ea2a690e7016f6e6d9a4"}, ] royalnet = [ - {file = "royalnet-5.7.4-py3-none-any.whl", hash = "sha256:45b43975098bef0319056dff5d46456cea7d5a88611b4a9f28b5eae88e0d99f5"}, - {file = "royalnet-5.7.4.tar.gz", hash = "sha256:8957d4894c866f0384bfcc94dce7f1f047b1eaaf0ffe0e0ab83d29232493bb53"}, + {file = "royalnet-5.7.5-py3-none-any.whl", hash = "sha256:d85afa59524482f8fa72f984cb9ec24e5517a0dfd280812097e766073fb98529"}, + {file = "royalnet-5.7.5.tar.gz", hash = "sha256:785dad6a8b9afaf6517ec30f06441265a3a57acf033e199706f1bc3156cd843a"}, ] royalspells = [ {file = "royalspells-3.2.tar.gz", hash = "sha256:2bd4a9a66514532e35c02c3907425af48c7cb292364c4843c795719a82b25dfe"}, diff --git a/pyproject.toml b/pyproject.toml index 01ea86e1..97d7bcba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,7 @@ steam = "^0.9.1" [tool.poetry.dependencies.royalnet] - version = "^5.7.4" + version = "^5.7.5" # Maybe... there is a way to make these selectable? extras = [ "telegram", diff --git a/royalpack/commands/matchmaking.py b/royalpack/commands/matchmaking.py index db277eab..7851399f 100644 --- a/royalpack/commands/matchmaking.py +++ b/royalpack/commands/matchmaking.py @@ -33,10 +33,11 @@ class MatchmakingCommand(Command): # Find all relevant MMEvents and run them session = self.alchemy.Session() mmevents = ( - session.query(self.alchemy.get(MMEvent)) - .filter(self.alchemy.get(MMEvent).interface == self.interface.name, - self.alchemy.get(MMEvent).datetime > datetime.datetime.now()) - .all() + session + .query(self.alchemy.get(MMEvent)) + .filter(self.alchemy.get(MMEvent).interface == self.interface.name, + self.alchemy.get(MMEvent).datetime > datetime.datetime.now()) + .all() ) for mmevent in mmevents: self.interface.loop.create_task(self._run_mmevent(mmevent.mmid)) @@ -71,7 +72,7 @@ class MatchmakingCommand(Command): data.session.add(mmevent) await data.session_commit() self.loop.create_task(self._run_mmevent(mmevent.mmid)) - await data.reply(f"✅ Evento [b]{mmevent.title}[/b] creato!") + await data.reply(f"✅ Matchmaking creato!") _mmchoice_values = { MMChoice.YES: 4, @@ -92,7 +93,8 @@ class MatchmakingCommand(Command): text += f"{response.choice.value} {response.user}\n" return text - def _gen_telegram_keyboard(self, mmevent: MMEvent): + @staticmethod + def _gen_telegram_keyboard(mmevent: MMEvent): if mmevent.datetime <= datetime.datetime.now(): return None return InKM([ @@ -142,18 +144,20 @@ class MatchmakingCommand(Command): mmresponse.choice = choice await data.session_commit() await self._update_telegram_mm_message(client, mmevent) - await data.reply(f"✅ Messaggio ricevuto!") + await data.reply(f"{choice.value} Messaggio ricevuto!") return callback - def _gen_event_start_message(self, mmevent: MMEvent): + @staticmethod + def _gen_event_start_message(mmevent: MMEvent): text = f"🚩 L'evento [b]{mmevent.title}[/b] è iniziato!\n\n" for response in mmevent.responses: response: MMResponse text += f"{response.choice.value} {response.user}\n" return text - def _gen_unauth_message(self, user: User): + @staticmethod + def _gen_unauth_message(user: User): return f"⚠ī¸ Non sono autorizzato a mandare messaggi a [b]{user.username}[/b]!\n" \ f"{user.telegram.mention()}, apri una chat privata con me e mandami un messaggio!" diff --git a/royalpack/commands/userinfo.py b/royalpack/commands/userinfo.py index 44f52774..e156a8e8 100644 --- a/royalpack/commands/userinfo.py +++ b/royalpack/commands/userinfo.py @@ -26,7 +26,7 @@ class UserinfoCommand(Command): user = found r = [ - f"ℹī¸ [b]{user.username}[/b]", + f"ℹī¸ [url=https://ryg.steffo.eu/#/user/{user.uid}]{user.username}[/url]", f"{user.role}", "", ] @@ -53,13 +53,14 @@ class UserinfoCommand(Command): r.append("") - r.append(f"Ha creato [b]{len(user.diario_created)}[/b] righe di diario, e vi compare in" + r.append(f"Ha creato [b]{len(user.diario_created)}[/b] righe di " + f"[url=https://ryg.steffo.eu/#/diario]Diario[/url], e vi compare in" f" [b]{len(user.diario_quoted)}[/b] righe.") r.append("") if user.trivia_score: - r.append(f"Ha [b]{user.trivia_score.score:.0f}[/b] punti trivia, avendo risposto correttamente a" + r.append(f"Ha [b]{user.trivia_score.score:.0f}[/b] punti Trivia, avendo risposto correttamente a" f" [b]{user.trivia_score.correct_answers}[/b] domande su" f" [b]{user.trivia_score.total_answers}[/b].") r.append("") diff --git a/royalpack/tables/diario.py b/royalpack/tables/diario.py index 8422214d..fcd5166a 100644 --- a/royalpack/tables/diario.py +++ b/royalpack/tables/diario.py @@ -88,7 +88,7 @@ class Diario: text += f" da {str(self.creator)}" text += f" il {self.timestamp.strftime('%Y-%m-%d %H:%M')}):\n" if self.media_url is not None: - text += f"{self.media_url}\n" + text += f"[url={self.media_url}]Media[/url]\n" if self.text is not None: if self.spoiler: hidden = re.sub(r"\w", "█", self.text)