Co-authored-by: AndrewLaneX <AndrewLaneX@users.noreply.github.com> Co-authored-by: Aditya <me@xditya.me> Co-authored-by: Danish <danish@ultroid.tech> Co-authored-by: buddhhu <buddhuu0@users.noreply.github.com> Co-authored-by: sppidy <sppidy@users.noreply.github.com> Co-authored-by: Arnab Paryali <Arnabxd@users.noreply.github.com> Co-authored-by: divkix <divkix@users.noreply.github.com> Co-authored-by: hellboi_atul <hellboi-atul@users.noreply.github.com> Co-authored-by: Programming Error <error@notavailable.live> Co-authored-by: New-dev0 <New-dev0@notavailable.live>
114 lines
3.0 KiB
Python
114 lines
3.0 KiB
Python
# 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}addfilter <word><reply to a message>`
|
|
add the used word as filter relating to replied message.
|
|
|
|
• `{i}remfilter <word>`
|
|
Remove the filtered user..
|
|
|
|
• `{i}listfilters`
|
|
list all filters.
|
|
"""
|
|
|
|
import os
|
|
|
|
from pyUltroid.functions.filter_db import *
|
|
from telegraph import upload_file as uf
|
|
from telethon.utils import pack_bot_file_id
|
|
|
|
from . import *
|
|
|
|
|
|
@ultroid_cmd(pattern="addfilter ?(.*)")
|
|
async def af(e):
|
|
wrd = e.pattern_match.group(1)
|
|
wt = await e.get_reply_message()
|
|
chat = e.chat_id
|
|
if not (wt and wrd):
|
|
return await eor(e, "`Use this command word to set as filter and reply...`")
|
|
try:
|
|
rem_filter(int(chat), wrd)
|
|
except:
|
|
pass
|
|
if wt and wt.media:
|
|
wut = mediainfo(wt.media)
|
|
if wut.startswith(("pic", "gif")):
|
|
dl = await bot.download_media(wt.media)
|
|
variable = uf(dl)
|
|
m = "https://telegra.ph" + variable[0]
|
|
elif wut == "video":
|
|
if wt.media.document.size > 8 * 1000 * 1000:
|
|
return await eod(x, "`Unsupported Media`")
|
|
else:
|
|
dl = await bot.download_media(wt.media)
|
|
variable = uf(dl)
|
|
os.remove(dl)
|
|
m = "https://telegra.ph" + variable[0]
|
|
else:
|
|
m = pack_bot_file_id(wt.media)
|
|
if wt.text:
|
|
add_filter(int(chat), wrd, wt.text, m)
|
|
else:
|
|
add_filter(int(chat), wrd, None, m)
|
|
else:
|
|
add_filter(int(chat), wrd, wt.text, None)
|
|
await eor(e, f"Done : Filter `{wrd}` Saved.")
|
|
|
|
|
|
@ultroid_cmd(pattern="remfilter ?(.*)")
|
|
async def rf(e):
|
|
wrd = e.pattern_match.group(1)
|
|
chat = e.chat_id
|
|
if not wrd:
|
|
return await eor(e, "`Give the filter to remove..`")
|
|
rem_filter(int(chat), wrd)
|
|
await eor(e, f"Done : Filter `{wrd}` Removed.")
|
|
|
|
|
|
@ultroid_cmd(pattern="listfilter$")
|
|
async def lsnote(e):
|
|
x = list_filter(e.chat_id)
|
|
if x:
|
|
sd = "Filters Found In This Chats Are\n\n"
|
|
await eor(e, sd + x)
|
|
else:
|
|
await eor(e, "No Filters Found Here")
|
|
|
|
|
|
@ultroid_bot.on(events.NewMessage())
|
|
async def fl(e):
|
|
xx = e.text
|
|
chat = e.chat_id
|
|
x = get_filter(int(chat))
|
|
if x:
|
|
if " " in xx:
|
|
xx = xx.split(" ")
|
|
kk = ""
|
|
for c in xx:
|
|
if c in x:
|
|
k = get_reply(int(chat), c)
|
|
if k:
|
|
kk = k
|
|
if kk:
|
|
msg = k["msg"]
|
|
media = k["media"]
|
|
await e.reply(msg, file=media)
|
|
|
|
else:
|
|
k = get_reply(chat, xx)
|
|
if k:
|
|
msg = k["msg"]
|
|
media = k["media"]
|
|
await e.reply(msg, file=media)
|
|
|
|
|
|
HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=HNDLR)}"})
|