mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 11:34:18 +00:00
✨ Add /emojify
This commit is contained in:
parent
208f009d96
commit
d0d8c50f14
8 changed files with 100 additions and 94 deletions
|
@ -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)
|
||||||
|
|
||||||
|
|
|
@ -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 *
|
|
||||||
|
|
|
@ -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")
|
||||||
|
|
|
@ -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",)
|
|
|
@ -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",
|
|
||||||
)
|
|
94
royalpack/commands/emojify.py
Normal file
94
royalpack/commands/emojify.py
Normal 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",)
|
|
@ -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!")
|
||||||
|
|
||||||
|
|
|
@ -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}")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue