diff --git a/strings.py b/strings.py
index 9b624ef7..a0848235 100644
--- a/strings.py
+++ b/strings.py
@@ -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: /eat (cibo)
"
+# Emojify a string
+class EMOJIFY:
+ RESPONSE = "{emojified}"
+
+ class ERRORS:
+ INVALID_SYNTAX = "โ Non hai specificato una frase!\nSintassi: /emojify (testo)
"
+
+
# Royalnet linking
class LINK:
SUCCESS = "โ
Collegamento riuscito!"
diff --git a/telegrambot.py b/telegrambot.py
index afe1a6c8..d7de53f3 100644
--- a/telegrambot.py
+++ b/telegrambot.py
@@ -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
diff --git a/utils/__init__.py b/utils/__init__.py
index 01a4947b..741ccd25 100644
--- a/utils/__init__.py
+++ b/utils/__init__.py
@@ -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"]
diff --git a/utils/emojify.py b/utils/emojify.py
new file mode 100644
index 00000000..69865b54
--- /dev/null
+++ b/utils/emojify.py
@@ -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
\ No newline at end of file