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

Add /emojify

This commit is contained in:
Steffo 2021-04-18 16:29:59 +02:00
parent 208f009d96
commit d0d8c50f14
Signed by: steffo
GPG key ID: 6965406171929D01
8 changed files with 100 additions and 94 deletions

View file

@ -49,11 +49,8 @@ register_telegram(commands.ciaoruozi, ["ciaoruozi"])
register_telegram(commands.color, ["color"]) register_telegram(commands.color, ["color"])
register_telegram(commands.ping, ["ping"]) register_telegram(commands.ping, ["ping"])
register_telegram(commands.ship, ["ship"], r"(?P<first>[A-Za-z]+)[\s+&]+(?P<second>[A-Za-z]+)") register_telegram(commands.ship, ["ship"], r"(?P<first>[A-Za-z]+)[\s+&]+(?P<second>[A-Za-z]+)")
register_telegram(commands.debug, ["debug"]) register_telegram(commands.emojify, ["emojify"], r"(?P<message>.+)")
register_telegram(commands.debug_impls, ["debug"], r"impls")
register_telegram(commands.debug_exts, ["debug"], r"exts (?P<impl>\S+)")
register_telegram(commands.debug_convs, ["debug"], r"convs (?P<impl>\S+)")
register_telegram(commands.ciao, ["ciao"])
pda.implementations["telethon.1"].register_conversation(r) pda.implementations["telethon.1"].register_conversation(r)

View file

@ -5,5 +5,4 @@ from .ciaoruozi import *
from .color import * from .color import *
from .ping import * from .ping import *
from .ship import * from .ship import *
from .debug import * from .emojify import *
from .ciao import *

View file

@ -10,7 +10,7 @@ log = logging.getLogger(__name__)
@engi.TeleportingConversation @engi.TeleportingConversation
async def cat(*, _sentry: engi.Sentry, _msg: engi.Message, **__): async def cat(*, _sentry: engi.Sentry, _msg: engi.Message, **__):
""" """
Send a cat in the chat! 🐈 Invia un gatto in chat! 🐈
""" """
log.debug("Creating a new HTTP session") log.debug("Creating a new HTTP session")

View file

@ -1,27 +0,0 @@
import royalnet.engineer as engi
import royalnet.engineer.conversation as c
@engi.TeleportingConversation
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

@ -1,57 +0,0 @@
import royalnet.engineer as engi
newline = "\n"
@engi.TeleportingConversation
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.TeleportingConversation
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.TeleportingConversation
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.TeleportingConversation
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,94 @@
import royalnet.engineer as engi
import random
_emojis = {
"abcd": ["🔡", "🔠"],
"back": ["🔙"],
"cool": ["🆒"],
"free": ["🆓"],
"1234": ["🔢"],
"abc": ["🔤"],
"atm": ["🏧"],
"new": ["🆕"],
"sos": ["🆘"],
"top": ["🔝"],
"zzz": ["💤"],
"end": ["🔚"],
"777": ["🎰"],
"100": ["💯"],
"ab": ["🆎"],
"cl": ["🆑"],
"id": ["🆔"],
"ng": ["🆖"],
"no": ["♑️"],
"ok": ["🆗"],
"on": ["🔛"],
"sy": ["💱"],
"tm": ["™️"],
"wc": ["🚾"],
"up": ["🆙"],
"!!": ["‼️"],
"!?": ["⁉️"],
"69": ["♋️"],
"24": ["🏪"],
"18": ["🔞"],
"10": ["🙌", "🔟", "🤲"],
"a": ["🅰️"],
"b": ["🅱️"],
"c": ["☪️", "©", "🥐"],
"d": ["🇩"],
"e": ["📧", "💶"],
"f": ["🎏"],
"g": ["🇬"],
"h": ["🏨", "🏩", "🏋‍♀", "🏋‍♂"],
"i": ["", "♊️", "🕕"],
"j": ["⤴️"],
"k": ["🎋", "🦅", "💃"],
"l": ["🛴", "🕒"],
"m": ["♏️", "Ⓜ️", "〽️"],
"n": ["📈"],
"o": ["⭕️", "🅾️", "📯", "🌝", "🌚", "🌕", "🥯", "🙆‍♀", "🙆‍♂"],
"p": ["🅿️"],
"q": ["🔍", "🍀", "🍭"],
"r": ["®"],
"s": ["💰", "💵", "💸", "💲"],
"t": ["✝️", "⬆️", "☦️"],
"u": ["", "⚓️", "🍉", "🌙", "🐋"],
"v": ["", "🔽", "☑️", "✔️"],
"w": ["🤷‍♀", "🤷‍♂", "🤾‍♀", "🤾‍♂", "🤽‍♀", "🤽‍♂"],
"x": ["🙅‍♀", "🙅‍♂", "", ""],
"y": ["💴"],
"z": ["⚡️"],
"*": ["*️⃣"],
"!": ["❗️", "", "⚠️"],
"?": ["", ""],
"9": ["9"],
"8": ["🎱", "8"],
"7": ["7"],
"6": ["6"],
"5": ["", "🤚", "👋", "5"],
"4": ["4"],
"3": ["🥉", "3"],
"2": ["✌️", "🤘", "🥈", "2"],
"1": ["👆", "☝️", "🖕", "🥇", "1"],
"0": ["⭕️", "🅾️", "📯", "🌝", "🌚", "🌕", "🥯", "🙆‍♀", "🙆‍♂", "0"],
"+": ["🏥"],
"/": ["🏒", "🧪", "🧹"],
"\\": ["🍢", "🍡", "🥄", "🌂"],
}
@engi.TeleportingConversation
async def emojify(*, _msg: engi.Message, message: str, **__):
"""
Converti un messaggio in emoji.
"""
message = message.lower()
for key in _emojis:
selected_emoji = random.sample(_emojis[key], 1)[0]
message = message.replace(key, selected_emoji)
await _msg.reply(text=message)
__all__ = ("emojify",)

View file

@ -4,7 +4,7 @@ import royalnet.engineer as engi
@engi.TeleportingConversation @engi.TeleportingConversation
async def ping(*, _sentry: engi.Sentry, _msg: engi.Message, **__): async def ping(*, _sentry: engi.Sentry, _msg: engi.Message, **__):
""" """
A way to check if the bot is working: it will always reply to this command with "🏓 Pong!". Gioca a ping pong con il bot. 🏓
""" """
await _msg.reply(text="🏓 Pong!") await _msg.reply(text="🏓 Pong!")

View file

@ -8,7 +8,7 @@ log = logging.getLogger(__name__)
@engi.TeleportingConversation @engi.TeleportingConversation
async def ship(*, _sentry: engi.Sentry, _msg: engi.Message, first: str, second: str, **__): async def ship(*, _sentry: engi.Sentry, _msg: engi.Message, first: str, second: str, **__):
""" """
Ship two names together! 💞 Shippa insieme due persone! 💞
""" """
log.info(f"Shipping: {first!r} + {second!r}") log.info(f"Shipping: {first!r} + {second!r}")