Files
Ultroid-fork/plugins/autocorrect.py
1Danish-00 6f44b386aa v0.2 11/10/2021
Co-authored-by: New-dev0 <New-dev0@users.noreply.github.com>
Co-authored-by: Amit Sharma <buddhhu@users.noreply.github.com>
Co-authored-by: TechiError <techierror@users.noreply.github.com>
Co-authored-by: Aditya <me@xditya.me>
Co-authored-by: Sonya Nikiforova <Sonniki@users.noreply.github.com>
Co-authored-by: M̲αραт <Marty2509@users.noreply.github.com>
Co-authored-by: Muhamad Risman Aziz <mrismanaziz@users.noreply.github.com>
Co-authored-by: Arnab Paryali <Arnabxd@users.noreply.github.com>
Co-authored-by: hellboi_atul <hellboi-atul@users.noreply.github.com>
Co-authored-by: sppidy <sppidy@users.noreply.github.com>
2021-10-11 00:27:23 +05:30

50 lines
1.3 KiB
Python

# Ultroid - UserBot
# Copyright (C) 2021 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}autocorrect`
To on/off Autocorrect Feature.
"""
import string
from gingerit.gingerit import GingerIt
from google_trans_new import google_translator
from telethon import events
from . import HNDLR, Redis, eor, get_string, udB, ultroid_bot, ultroid_cmd
@ultroid_cmd(pattern="autocorrect", fullsudo=True)
async def acc(e):
if Redis("AUTOCORRECT") != "True":
udB.set("AUTOCORRECT", "True")
return await eor(e, get_string("act_1"), time=5)
udB.delete("AUTOCORRECT")
await eor(e, get_string("act_2"), time=5)
@ultroid_bot.on(events.NewMessage(outgoing=True, func=lambda x: x.text))
async def gramme(event):
if Redis("AUTOCORRECT") != "True":
return
t = event.text
if t[0] == HNDLR or t[0].lower() not in string.ascii_lowercase or t.endswith(".."):
return
tt = google_translator().detect(t)
if tt[0] != "en":
return
xx = GingerIt()
x = xx.parse(t)
res = x["result"]
try:
await event.edit(res)
except BaseException:
pass