forked from TeamUltroid/UltroidAddons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
morsecode.py
39 lines (31 loc) · 1.24 KB
/
morsecode.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Ultroid - UserBot
#
# This file is a part of < https://github.com/TeamUltroid/UltroidAddons/ >
# PLease read the GNU Affero General Public License in
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
"""
✘ Commands Available -
• `{i}mencode <text>`
Encode the given text to Morse Code.
• `{i}mdecode <text>`
Decode the given text from Morse Code.
"""
from . import async_searcher, ultroid_cmd
@ultroid_cmd(pattern="mencode ?(.*)")
async def mencode(event):
msg = await event.eor("`Processing...`")
text = event.pattern_match.group(1)
if not text:
return msg.edit("Please give a text!")
base_url = "https://apis.xditya.me/morse/encode?text=" + text
encoded = await async_searcher(base_url, re_content=False)
await msg.edit("**Encoded.**\n\n**Morse Code:** `{}`".format(encoded))
@ultroid_cmd(pattern="mdecode ?(.*)")
async def mencode(event):
msg = await event.eor("`Processing...`")
text = event.pattern_match.group(1)
if not text:
return await msg.edit("Please give a text!")
base_url = "https://apis.xditya.me/morse/decode?text=" + text
encoded = await async_searcher(base_url, re_content=False)
await msg.edit("**Decoded.**\n\n**Message:** `{}`".format(encoded))