From 57f832b3207a6bf4a8adaa75d788a541211c787a Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 8 May 2021 02:00:57 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20/rocoinflip=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- royalpack/__main__.py | 2 ++ royalpack/commands/__init__.py | 1 + royalpack/commands/rocoinflip.py | 28 ++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 royalpack/commands/rocoinflip.py diff --git a/royalpack/__main__.py b/royalpack/__main__.py index 6f58c501..b1415ee4 100644 --- a/royalpack/__main__.py +++ b/royalpack/__main__.py @@ -108,6 +108,7 @@ register_telegram(tg_router, commands.fiorygi_dig, ["dig"], r"(?P[a-z0-9-] register_telegram(tg_router, commands.fiorygi_bury, ["bury"], r"(?P[a-z0-9-]+)\s+(?P[0-9]+)(?:\s+(?P.+))?") register_telegram(tg_router, commands.version, ["version"]) register_telegram(tg_router, commands.cv, ["cv", "civù"]) +register_telegram(tg_router, commands.rocoinflip, ["rocoinflip"], r'"(?P[^"]+)"\s+"(?P[^"]+)"') ds_router = engi.Router() @@ -138,6 +139,7 @@ register_discord(ds_router, commands.fiorygi_transactions_other, ["transactions" register_discord(ds_router, commands.fiorygi_dig, ["dig"], r"(?P[a-z0-9-]+)") register_discord(ds_router, commands.fiorygi_bury, ["bury"], r"(?P[a-z0-9-]+)\s+(?P[0-9]+)(?:\s+(?P.+))?") register_discord(ds_router, commands.version, ["version"]) +register_discord(ds_router, commands.rocoinflip, ["rocoinflip"], r'"(?P[^"]+)"\s+"(?P[^"]+)"') pda.implementations["telethon.1"].register_conversation(tg_router) pda.implementations["discordpy.2"].register_conversation(ds_router) diff --git a/royalpack/commands/__init__.py b/royalpack/commands/__init__.py index 58d09d40..101493f8 100644 --- a/royalpack/commands/__init__.py +++ b/royalpack/commands/__init__.py @@ -17,3 +17,4 @@ from .whoami import * from .fiorygi import * from .version import * from .cv import * +from .rocoinflip import * diff --git a/royalpack/commands/rocoinflip.py b/royalpack/commands/rocoinflip.py new file mode 100644 index 00000000..d0218436 --- /dev/null +++ b/royalpack/commands/rocoinflip.py @@ -0,0 +1,28 @@ +import random +import royalnet.engineer as engi + + +@engi.TeleportingConversation +async def rocoinflip(*, _sentry: engi.Sentry, _msg: engi.Message, teama: str, teamb: str, **__): + """ + Scegli quale delle due squadre inizierà per prima. + """ + flip = random.randrange(0, 2) + if flip == 0: + first = teama + second = teamb + else: + first = teamb + second = teama + + text = [ + f"❔ Risultati del coin flip:", + f"", + f"🔹 {first}", + f"🔸 {second}", + ] + + await _msg.reply(text="\n".join(text)) + + +__all__ = ("rocoinflip",)