1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 03:24:20 +00:00

💥 Possibly progress but also a mess

This commit is contained in:
Steffo 2021-04-15 02:40:51 +02:00
parent b678467153
commit d1a4cb24d4
Signed by: steffo
GPG key ID: 6965406171929D01
7 changed files with 171 additions and 24 deletions

42
poetry.lock generated
View file

@ -59,7 +59,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
name = "click"
version = "7.1.2"
description = "Composable command line interface toolkit"
category = "dev"
category = "main"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
@ -67,7 +67,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
name = "colorama"
version = "0.4.4"
description = "Cross-platform colored terminal text."
category = "dev"
category = "main"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
@ -127,7 +127,7 @@ python-versions = ">=3.6"
name = "psutil"
version = "5.8.0"
description = "Cross-platform lib for process and system monitoring in Python."
category = "dev"
category = "main"
optional = false
python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
@ -146,7 +146,7 @@ python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*"
name = "pyaes"
version = "1.6.1"
description = "Pure-Python Implementation of the AES block-cipher and common modes of operation"
category = "dev"
category = "main"
optional = false
python-versions = "*"
@ -154,7 +154,7 @@ python-versions = "*"
name = "pyasn1"
version = "0.4.8"
description = "ASN.1 types and codecs"
category = "dev"
category = "main"
optional = false
python-versions = "*"
@ -183,7 +183,7 @@ python-versions = "*"
[[package]]
name = "royalnet"
version = "6.2.10"
version = "6.3.0"
description = "A multipurpose bot framework"
category = "main"
optional = false
@ -197,9 +197,9 @@ toml = ">=0.10.1,<0.11.0"
[[package]]
name = "royalnet-console"
version = "2.0.1"
version = "2.0.2"
description = "A terminal-based frontend for the royalnet.engineer module."
category = "dev"
category = "main"
optional = false
python-versions = ">=3.8,<4.0"
@ -207,26 +207,26 @@ python-versions = ">=3.8,<4.0"
click = ">=7.1.2,<8.0.0"
colorama = ">=0.4.4,<0.5.0"
psutil = ">=5.8.0,<6.0.0"
royalnet = ">=6.2.0,<6.3.0"
royalnet = ">=6.3.0,<6.4.0"
[[package]]
name = "royalnet-telethon"
version = "0.3.1"
version = "1.0.0"
description = "A Telethon-based frontend for the royalnet.engineer module."
category = "dev"
category = "main"
optional = false
python-versions = ">=3.8,<4.0"
[package.dependencies]
click = ">=7.1.2,<8.0.0"
royalnet = ">=6.2.10,<6.3.0"
royalnet = ">=6.3.0,<6.4.0"
Telethon = ">=1.21.1,<2.0.0"
[[package]]
name = "rsa"
version = "4.7.2"
description = "Pure-Python RSA implementation"
category = "dev"
category = "main"
optional = false
python-versions = ">=3.5, <4"
@ -268,7 +268,7 @@ sqlcipher = ["sqlcipher3-binary"]
name = "telethon"
version = "1.21.1"
description = "Full-featured Telegram client library for Python 3"
category = "dev"
category = "main"
optional = false
python-versions = ">=3.5"
@ -310,7 +310,7 @@ multidict = ">=4.0"
[metadata]
lock-version = "1.1"
python-versions = "^3.8"
content-hash = "22fc870d53f6152b719e9e0fad1ff1d77961e68a52a4cb09765e203dd4c72ece"
content-hash = "41b994185949507e7f8285280a484f57179679c337ba81d18ab8fde6945e758c"
[metadata.files]
aiohttp = [
@ -567,16 +567,16 @@ pyreadline = [
{file = "pyreadline-2.1.zip", hash = "sha256:4530592fc2e85b25b1a9f79664433da09237c1a270e4d78ea5aa3a2c7229e2d1"},
]
royalnet = [
{file = "royalnet-6.2.10-py3-none-any.whl", hash = "sha256:794d2f2c5d319a1649cf97355d7ad07c0ad36df4d96b4ad534eb1dc1c4a39caa"},
{file = "royalnet-6.2.10.tar.gz", hash = "sha256:1a3f87b77fccce8df7571fcd0d8fbc5837b9f173a6d15c5e1e3e679a377b8ba5"},
{file = "royalnet-6.3.0-py3-none-any.whl", hash = "sha256:f2f6ea15def33e27ca92a0ba3b7863fab7b7339bcbb99bc83f6be74bd8e805e6"},
{file = "royalnet-6.3.0.tar.gz", hash = "sha256:6301ef60a1402ec59e55a206462f5b7296c5f6bbd6ab0bf38851ede42add5b20"},
]
royalnet-console = [
{file = "royalnet-console-2.0.1.tar.gz", hash = "sha256:33b054157447bbf8bac7f711548395d028ca677b16624108e932ec94c428f46c"},
{file = "royalnet_console-2.0.1-py3-none-any.whl", hash = "sha256:de262fa8fa9072fc90cc8cf4e891b950bbfd25a9918571a63f609d81c8f435c5"},
{file = "royalnet-console-2.0.2.tar.gz", hash = "sha256:ea8e8fb9f3da51f9845f7b8841bc5d971a805bbc765970fe2a76603a49d29b1e"},
{file = "royalnet_console-2.0.2-py3-none-any.whl", hash = "sha256:c9505dc37c8f8b9a4bb96687622f00e4516b44b8bb29ad8edd5d0acf40872487"},
]
royalnet-telethon = [
{file = "royalnet-telethon-0.3.1.tar.gz", hash = "sha256:2d6b9e364d09da3357822abeeab12663f6097248f4489909d0b20030b5791b0a"},
{file = "royalnet_telethon-0.3.1-py3-none-any.whl", hash = "sha256:24953539fb947d60aff05b558753a4e96a8ddd0b1aa8aca744d06995ef56f1b1"},
{file = "royalnet-telethon-1.0.0.tar.gz", hash = "sha256:361e64f06ccdae541dd97669066b91ea36d374d57a51d07703be490ef362e867"},
{file = "royalnet_telethon-1.0.0-py3-none-any.whl", hash = "sha256:1879cf8bc00f25bf0809e22da319f631e266fae3073c371893a4057f30bdbb02"},
]
rsa = [
{file = "rsa-4.7.2-py3-none-any.whl", hash = "sha256:78f9a9bf4e7be0c5ded4583326e7461e3a3c5aae24073648b4bdfa797d78c9d2"},

View file

@ -37,11 +37,19 @@ pda = engi.PDA(implementations=[
pda.implementations["telethon.1"].register_partialcommand(commands.ahnonlosoio, ["ahnonlosoio"])
pda.implementations["telethon.1"].register_partialcommand(commands.answer, ["answer"])
pda.implementations["telethon.1"].register_partialcommand(commands.cat, ["cat"])
pda.implementations["telethon.1"].register_partialcommand(commands.ciaoruozi, ["ciaoruozi"])
pda.implementations["telethon.1"].register_partialcommand(commands.color, ["color"])
pda.implementations["telethon.1"].register_partialcommand(commands.ping, ["ping"])
pda.implementations["telethon.1"].register_partialcommand(commands.ship, ["ship"])
pda.implementations["telethon.1"].register_partialcommand(commands.rage_show, ["rage"])
pda.implementations["telethon.1"].register_partialcommand(commands.rage_add, ["rage"])
pda.implementations["telethon.1"].register_partialcommand(commands.debug, ["debug"])
pda.implementations["telethon.1"].register_partialcommand(commands.debug_impls, ["debug"])
pda.implementations["telethon.1"].register_partialcommand(commands.debug_exts, ["debug"])
pda.implementations["telethon.1"].register_partialcommand(commands.debug_convs, ["debug"])
pda.implementations["telethon.1"].register_partialcommand(commands.ciao, ["ciao"])
pda.implementations["telethon.1"].register_partialcommand(commands.help_cmd, ["help"])
pda.implementations["telethon.1"].register_partialcommand(commands.help_single, ["help"])
pda.run()

View file

@ -1,7 +1,11 @@
from .ahnonlosoio import *
from .answer import *
from .cat import *
from .ciaoruozi import *
from .color import *
from .ping import *
from .ship import *
from .rage import *
from .debug import *
from .ciao import *
from .help import *

View file

@ -0,0 +1,26 @@
import royalnet.engineer as engi
@engi.PartialCommand.new(syntax="", lock=False)
async def ciao(*, _sentry: engi.Sentry, _msg: engi.Message, **__):
await _msg.reply(text="👋 Ciao, chi sei?")
answer: engi.MessageReceived = await _sentry.filter(engi.Type(engi.MessageReceived)).get()
_msg: engi.Message = await answer.message
_text: str = await _msg.text
await _msg.reply(text=f"👋 Ciao {_text}! Come stai?")
answer: engi.MessageReceived = await _sentry.filter(engi.Type(engi.MessageReceived)).get()
_msg: engi.Message = await answer.message
_text: str = await _msg.text
if "mamma" in _text or "madre" in _text:
await _msg.reply(text=f"😐 Ehi... Al massimo sono io quello che sta {_text}!")
elif "male" in _text:
await _msg.reply(text=f"☹️ Mi dispiace che tu stia {_text}... :(")
else:
await _msg.reply(text=f"🙂 Anche io sto {_text} :)")
__all__ = ("ciao",)

View file

@ -4,12 +4,12 @@ import royalnet_telethon.bullet.contents as rtc
@engi.PartialCommand.new(syntax="")
async def ciaoruozi(*, _sentry: engi.Sentry, _msg: engi.Message, _pda, **__):
async def ciaoruozi(*, _sentry: engi.Sentry, _msg: engi.Message, _imp, **__):
"""
Saluta Ruozi, una creatura leggendaria che potrebbe esistere o non esistere in Royal Games.
"""
if isinstance(_pda, rt.TelethonPDA):
if isinstance(_imp, rt.TelethonPDAImplementation):
sender: rtc.TelegramUser = await _msg.sender
# noinspection PyProtectedMember
if sender._user.id == 112437036:
@ -18,4 +18,4 @@ async def ciaoruozi(*, _sentry: engi.Sentry, _msg: engi.Message, _pda, **__):
await _msg.reply(text="👋 Ciao Ruozi!")
__all__ = ("color",)
__all__ = ("ciaoruozi",)

View file

@ -0,0 +1,57 @@
import royalnet.engineer as engi
import royalnet_telethon as rt
newline = "\n"
@engi.PartialCommand.new(syntax="")
async def debug(*, _sentry: engi.Sentry, _msg: engi.Message, _pda: engi.PDA, **__):
"""
Check the implementations currently running on the PDA.
"""
await _msg.reply(text=f"""
🐛 Sottocomandi di debug disponibili:
- impls
- commands
""")
@engi.PartialCommand.new(syntax=r"impls")
async def debug_impls(*, _sentry: engi.Sentry, _msg: engi.Message, _pda: engi.PDA, **__):
await _msg.reply(text=f"""
🐛 Implementazioni attive sul PDA:
{newline.join([f'🔵 {implementation!r}' for implementation in _pda.implementations.values()])}
""")
@engi.PartialCommand.new(syntax=r"exts (?P<impl>\S+)")
async def debug_exts(*, _sentry: engi.Sentry, _msg: engi.Message, _pda: engi.PDA, impl: str, **__):
await _msg.reply(text=f"""
🐛 Estensioni attive sull'implementazione {impl}:
{newline.join([f'🔵 {extension!r}' for extension in _pda.implementations[impl].extensions])}
""")
@engi.PartialCommand.new(syntax=r"convs (?P<impl>\S+)")
async def debug_convs(*, _sentry: engi.Sentry, _msg: engi.Message, _pda: engi.PDA, impl: str, **__):
implementation = _pda.implementations[impl]
if not isinstance(implementation, engi.ConversationListImplementation):
await _msg.reply(text="⚠️ Questa implementazione gestisce le conversazioni con un metodo sconosciuto.")
await _msg.reply(text=f"""
🐛 Conversazioni registrate sull'implementazione {impl}:
{newline.join([f'🔵 {command!r}' for command in implementation.conversations])}
""")
__all__ = (
"debug",
"debug_impls",
"debug_exts",
"debug_convs",
)

View file

@ -0,0 +1,52 @@
import royalnet.engineer as engi
@engi.PartialCommand.new(syntax=r"")
async def help_cmd(*, _sentry: engi.Sentry, _imp: engi.PDAImplementation, _msg: engi.Message, **__):
if not isinstance(_imp, engi.ConversationListImplementation):
await _msg.reply(text="⚠️ Questa implementazione gestisce i comandi con un metodo sconosciuto.")
commands = [command for command in _imp.conversations if isinstance(command, engi.FullCommand)]
names = set([command.name() for command in commands])
text = [" Comandi disponibili:"]
for name in names:
text.append(f"- {name}")
text = "\n".join(text)
await _msg.reply(text=text)
@engi.PartialCommand.new(syntax=r"(?P<cmd>\S+)")
async def help_single(*, _sentry: engi.Sentry, _imp: engi.PDAImplementation, _msg: engi.Message, cmd: str, **__):
if not isinstance(_imp, engi.ConversationListImplementation):
await _msg.reply(text="⚠️ Questa implementazione gestisce i comandi con un metodo sconosciuto.")
commands = [
command
for command in _imp.conversations
if isinstance(command, engi.FullCommand)
and cmd in command.names
]
text = [f" Sottocomandi di {cmd} disponibili:"]
for command in commands:
text.append("")
text.append("")
text.append(f"{command}")
text.append(f" {command.pattern.pattern}")
text.append("")
if ht := command.help():
text.append(ht.strip())
else:
text.append("Questo comando non ha un help text.")
text = "\n".join(text)
await _msg.reply(text=text)
__all__ = (
"help_cmd",
"help_single",
)