-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeBase64.py
More file actions
59 lines (43 loc) · 2.18 KB
/
CodeBase64.py
File metadata and controls
59 lines (43 loc) · 2.18 KB
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
54
55
56
57
58
59
# █▀▀ ▄▀█ █▀▄▀█ █▀█ █▀▄ █▀
# █▀░ █▀█ █░▀░█ █▄█ █▄▀ ▄█
# https://t.me/famods
# 🔒 Licensed under the GNU AGPLv3
# 🌐 https://www.gnu.org/licenses/agpl-3.0.html
# ---------------------------------------------------------------------------------
# Name: CodeBase64
# Description: Encode and decode base64
# meta developer: @FAmods
# meta banner: https://github.com/FajoX1/FAmods/blob/main/assets/banners/CodeBase64.png?raw=true
# ---------------------------------------------------------------------------------
import base64
import asyncio
import logging
from .. import loader, utils
logger = logging.getLogger(__name__)
@loader.tds
class CodeBase64(loader.Module):
"""Encode and decode base64"""
strings = {
"name": "CodeBase64",
"only_base64": "<b><emoji document_id=5019523782004441717>🚫</emoji> Only <code>base64</code></b>",
"enc_txt": "<b><emoji document_id=6334316848741352906>⌨️</emoji> You encoded text into base64:</b>\n<code>{}</code>",
"de_txt": "<b><emoji document_id=6334316848741352906>⌨️</emoji> You decoded text from base64:</b>\n<code>{}</code>",
}
async def client_ready(self, client, db):
self.db = db
self._client = client
@loader.command()
async def cbase64(self, message):
"""Кодирование в base64"""
enc_bytes = base64.b64encode(utils.get_args_raw(message).encode('utf-8'))
enc_text = enc_bytes.decode('utf-8') # Декодируем байты в строку
await utils.answer(message, self.strings["enc_txt"].format(enc_text))
@loader.command()
async def dbase64(self, message):
"""Декодирование из base64"""
try:
de_bytes = base64.b64decode(utils.get_args_raw(message))
except:
return await utils.answer(message, self.strings['only_base64'])
de_text = de_bytes.decode('utf-8') # Декодируем байты в строку
await utils.answer(message, self.strings["de_txt"].format(de_text))