From b4665a407be947050e15fa126b6f50c748fc5313 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 25 Apr 2021 23:33:35 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20/version=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- royalpack/__main__.py | 1 + royalpack/commands/__init__.py | 1 + royalpack/commands/version.py | 28 ++++++++++++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 royalpack/commands/version.py diff --git a/royalpack/__main__.py b/royalpack/__main__.py index 591cd143..50530f98 100644 --- a/royalpack/__main__.py +++ b/royalpack/__main__.py @@ -65,6 +65,7 @@ register_telegram(commands.fiorygi_transactions_self, ["transactions"]) register_telegram(commands.fiorygi_transactions_other, ["transactions"], r"(?P\S+)") register_telegram(commands.fiorygi_dig, ["dig"], r"(?P[a-z0-9-]+)") register_telegram(commands.fiorygi_bury, ["bury"], r"(?P[a-z0-9-]+)\s+(?P[0-9]+)(?:\s+(?P.+))?") +register_telegram(commands.version, ["version"]) pda.implementations["telethon.1"].register_conversation(r) diff --git a/royalpack/commands/__init__.py b/royalpack/commands/__init__.py index fa465e3b..bd9da5f7 100644 --- a/royalpack/commands/__init__.py +++ b/royalpack/commands/__init__.py @@ -15,3 +15,4 @@ from .man import * from .login import * from .whoami import * from .fiorygi import * +from .version import * \ No newline at end of file diff --git a/royalpack/commands/version.py b/royalpack/commands/version.py new file mode 100644 index 00000000..876daad8 --- /dev/null +++ b/royalpack/commands/version.py @@ -0,0 +1,28 @@ +import royalnet.engineer as engi +import royalnet_telethon as rt +import pkg_resources + + +@engi.TeleportingConversation +async def version(*, _imp: engi.PDAImplementation, _msg: engi.Message, **__): + """ + Controlla la versione attuale dei pacchetti di questo bot. + """ + + # noinspection PyListCreation + msg = [ + f"ℹ️ \uE01BVersioni\uE00B", + ] + + msg.append("") + msg.append(f"- \uE01Croyalnet\uE00C \uE01B{pkg_resources.get_distribution('royalnet').version}\uE00B") + + if isinstance(_imp, rt.TelethonPDAImplementation): + msg.append(f"- \uE01Croyalnet_telethon\uE00C \uE01B{pkg_resources.get_distribution('royalnet_telethon').version}\uE00B") + + msg.append(f"- \uE01Croyalpack\uE00C \uE01B{pkg_resources.get_distribution('royalpack').version}\uE00B") + + await _msg.reply(text="\n".join(msg)) + + +__all__ = ("version",)