-
-
Notifications
You must be signed in to change notification settings - Fork 301
/
encodedecode.py
53 lines (44 loc) · 1.47 KB
/
encodedecode.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Ultroid - UserBot
# Copyright (C) 2020 TeamUltroid
#
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
"""
✘ Commands Available -
• {i}encode <text/reply to message>
encode the text
• {i}decode <text/reply to message>
decode the text
"""
import base64
from . import ultroid_cmd
@ultroid_cmd(pattern="encode ?(.*)")
async def encod(e):
match = e.pattern_match.group(1)
if not match and e.is_reply:
gt = await e.get_reply_message()
if gt.text:
match = gt.text
if not (match or e.is_reply):
return await e.eor("`Give me Something to Encode..`")
byt = match.encode("ascii")
et = base64.b64encode(byt)
atc = et.decode("ascii")
await e.eor(f"**=>> Encoded Text :** `{match}`\n\n**=>> OUTPUT :**\n`{atc}`")
@ultroid_cmd(pattern="decode ?(.*)")
async def encod(e):
match = e.pattern_match.group(1)
if not match and e.is_reply:
gt = await e.get_reply_message()
if gt.text:
match = gt.text
if not (match or e.is_reply):
return await e.eor("`Give me Something to Decode..`")
byt = match.encode("ascii")
try:
et = base64.b64decode(byt)
atc = et.decode("ascii")
await e.eor(f"**=>> Decoded Text :** `{match}`\n\n**=>> OUTPUT :**\n`{atc}`")
except Exception as p:
await e.eor("**ERROR :** " + str(p))