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

Add /emojify (thanks @Pandiscotto!)

This commit is contained in:
Steffo 2019-02-19 19:37:17 +01:00
parent 68d167208d
commit 714c969697
4 changed files with 81 additions and 4 deletions

View file

@ -32,6 +32,7 @@ class TELEGRAM:
PONG = "🏓 Pong!"
ESCAPE = "{text}"
# Ah, non lo so io.
@ -105,6 +106,14 @@ class EAT:
INVALID_SYNTAX = "⚠ Non hai specificato cosa mangiare!\nSintassi: <code>/eat (cibo)</code>"
# Emojify a string
class EMOJIFY:
RESPONSE = "{emojified}"
class ERRORS:
INVALID_SYNTAX = "⚠ Non hai specificato una frase!\nSintassi: <code>/emojify (testo)</code>"
# Royalnet linking
class LINK:
SUCCESS = "✅ Collegamento riuscito!"

View file

@ -2,7 +2,7 @@ import datetime
import random
import typing
import db
from utils import smecds, cast, errors
from utils import smecds, cast, errors, emojify
# python-telegram-bot has a different name
# noinspection PyPackageRequirements
import telegram
@ -772,14 +772,25 @@ def cmd_start(bot: telegram.Bot, update: telegram.Update):
@command
def cmd_spell(bot: telegram.Bot, update: telegram.Update):
try:
input: str = update.message.text.split(" ", 1)[1]
spell_name: str = update.message.text.split(" ", 1)[1]
except IndexError:
reply(bot, update, strings.SPELL.ERRORS.INVALID_SYNTAX)
return
spell = cast.Spell(input)
spell = cast.Spell(spell_name)
reply(bot, update, spell.stringify())
@command
def cmd_emojify(bot: telegram.Bot, update: telegram.Update):
try:
string: str = update.message.text.split(" ", 1)[1]
except IndexError:
reply(bot, update, strings.EMOJIFY.ERRORS.INVALID_SYNTAX)
return
msg = emojify(string)
reply(bot, update, strings.EMOJIFY.RESPONSE, emojified=msg)
def process(arg_discord_connection):
if arg_discord_connection is not None:
global discord_connection

View file

@ -2,5 +2,6 @@ from .dirty import Dirty, DirtyDelta
from .mmstatus import MatchmakingStatus
from .cast import Spell
from .stagismo import smecds
from .emojify import emojify
__all__ = ["Dirty", "DirtyDelta", "MatchmakingStatus", "Spell", "smecds"]
__all__ = ["Dirty", "DirtyDelta", "MatchmakingStatus", "Spell", "smecds", "emojify"]

56
utils/emojify.py Normal file
View file

@ -0,0 +1,56 @@
import random
emojis = {
"abcd": ["🔡", "🔠"],
"back": ["🔙"],
"cool": ["🆒"],
"free": ["🆓"],
"abc": ["🔤"],
"atm": ["🏧"],
"new": ["🆕"],
"sos": ["🆘"],
"top": ["🔝"],
"zzz": ["💤"],
"end": ["🔚"],
"ab": ["🆎"],
"cl": ["🆑"],
"id": ["🆔"],
"ng": ["🆖"],
"no": ["♑️"],
"ok": ["🆗"],
"on": ["🔛"],
"sy": ["💱"],
"tm": ["™️"],
"wc": ["🚾"],
"up": ["🆙"],
"a": ["🅰️", "🎣"],
"b": ["🅱️", "🇳🇵"],
"c": ["☪️", "©", "🥐"],
"e": ["📧", "💶"],
"f": ["🎏"],
"h": ["🏨", "🏩", "🏋‍♀", "🏋‍♂"],
"i": ["", "♊️", "🕴", "🕕"],
"j": ["🧜‍♀", "🧜‍♂", "🤳", "🏒", "🏑", "⤴️"],
"k": ["🎋", "🦅", "💃"],
"l": ["🛴", "🕒"],
"m": ["♏️", "Ⓜ️", "〽️"],
"n": ["📈"],
"o": ["⭕️", "🅾️", "📯", "🌝", "🌚", "🌕", "🥯", "🙆‍♀", "🙆‍♂"],
"p": ["🅿️"],
"q": ["🔍", "🍀"],
"r": ["®"],
"s": ["💰", "💵", "💸", "💲", "🧞‍♀", "🧞‍♂"],
"t": ["🤸‍♀", "🤸‍♂", "✝️", "⬆️", "🔨", "☦️", "🚏"],
"u": ["", "⚓️", "🍉", "🌙", "🐋"],
"v": ["", "🔽", "☑️", "✔️"],
"w": ["🤷‍♀","🤷‍♂", "🤾‍♀", "🤾‍♂", "🤽‍♀", "🤽‍♂"],
"x": ["🙅‍♀", "🙅‍♂", "🇯🇲", "🇯🇪", "", ""],
"z": ["⚡️", "🔋"]
}
def emojify(string: str):
new_string = string
for key in emojis:
selected_emoji = random.sample(emojis[key], 1)[0]
new_string = new_string.replace(key, selected_emoji)
return new_string