-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathyg_base64.py
48 lines (36 loc) · 1.81 KB
/
yg_base64.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
__version__ = (1, 4, 8, 8)
# This file is a part of Hikka Userbot
# Code is NOT licensed under CC-BY-NC-ND 4.0 unless otherwise specified.
# 🌐 https://github.com/hikariatama/Hikka
# You CAN edit this file without direct permission from the author.
# You can redistribute this file with any modifications.
# meta developer: @yg_modules
# scope: hikka_only
# scope: hikka_min 1.6.3
# █▄█ █░█ █▀▄▀█ █▀▄▀█ █▄█ █▀▄▀█ █▀█ █▀▄ █▀
# ░█░ █▄█ █░▀░█ █░▀░█ ░█░ █░▀░█ █▄█ █▄▀ ▄█
import base64
from .. import loader, utils
@loader.tds
class yg_base64(loader.Module):
"""Encode and decode text using Base64"""
strings = {"name": "yg_base64"}
async def encodecmd(self, message):
"""<text> encode the provided text using Base64"""
text = utils.get_args_raw(message)
if not text:
await utils.answer(message, "<b>No text provided to encode.</b>")
return
encoded_text = base64.b64encode(text.encode("utf-8")).decode("utf-8")
await utils.answer(message, f"<b>Encoded text:</b> <code>{encoded_text}</code>")
async def decodecmd(self, message):
"""<text> decode the provided Base64 encoded text"""
text = utils.get_args_raw(message)
if not text:
await utils.answer(message, "<b>No encoded text provided to decode</b>")
return
try:
decoded_text = base64.b64decode(text).decode("utf-8")
await utils.answer(message, f"<b>Decoded text:</b> <code>{decoded_text}</code>")
except Exception as e:
await utils.answer(message, f"<b>Error decoding text:</b> <code>{str(e)}</code>")