From a8b52e663966a978e4c4805cd933bd3c588c9093 Mon Sep 17 00:00:00 2001
From: thedragonsinn <98635854+thedragonsinn@users.noreply.github.com>
Date: Wed, 4 Oct 2023 18:52:36 +0530
Subject: [PATCH] WiP-Fbans: Listf and Fbanp.
---
app/plugins/fbans.py | 53 ++++++++++++++++++++++++++++++++------------
1 file changed, 39 insertions(+), 14 deletions(-)
diff --git a/app/plugins/fbans.py b/app/plugins/fbans.py
index c4a96de..27b0679 100644
--- a/app/plugins/fbans.py
+++ b/app/plugins/fbans.py
@@ -27,12 +27,14 @@ class _User(User):
@bot.add_cmd(cmd="addf")
async def add_fed(bot: bot, message: Message):
- data = dict(
- name=message.input or message.chat.title, type=str(message.chat.type)
- )
+ data = dict(name=message.input or message.chat.title, type=str(message.chat.type))
await add_data(collection=FEDS, id=message.chat.id, data=data)
- await message.reply(f"{data['name']} added to FED LIST.", del_in=5, block=False)
- await bot.log(text=f"#FBANS\n{data['name']} {message.chat.id} added to FED LIST.")
+ await message.reply(
+ f"{data['name']} added to FED LIST.", del_in=5, block=False
+ )
+ await bot.log(
+ text=f"#FBANS\n{data['name']} {message.chat.id} added to FED LIST."
+ )
@bot.add_cmd(cmd="delf")
@@ -51,14 +53,18 @@ async def remove_fed(bot: bot, message: Message):
deleted: bool | None = await delete_data(collection=FEDS, id=chat)
if deleted:
await message.reply(
- f"{name}{chat} removed from FED LIST.", del_in=8, block=False
+ f"{name}{chat} removed from FED LIST.",
+ del_in=8,
+ block=False,
+ )
+ await bot.log(
+ text=f"#FBANS\n{name}{chat} removed from FED LIST."
)
- await bot.log(text=f"#FBANS\n{name}{chat} removed from FED LIST.")
else:
await message.reply(f"{name or chat} not in FED LIST.", del_in=8)
-@bot.add_cmd(cmd="fban")
+@bot.add_cmd(cmd=["fban", "fbanp"])
async def fed_ban(bot: bot, message: Message):
await message.delete()
progress: Message = await message.reply("❯")
@@ -71,20 +77,24 @@ async def fed_ban(bot: bot, message: Message):
if user.id in Config.USERS:
await progress.edit("Cannot Fban Owner/Sudo users.")
return
+ proof_str: str = ""
+ if message.cmd == "fbanp":
+ if not message.replied:
+ await message.reply("Reply to a proof")
+ proof = await message.replied.forward(Config.FBAN_LOG_CHANNEL)
+ proof_str = "".join(["{ ", proof.link, " }"])
+
await progress.edit("❯❯")
total: int = 0
failed: list[str] = []
+ cmd: str = f"/fban {user.mention} {reason}\n{proof_str}"
async for fed in FEDS.find():
chat_id = int(fed["_id"])
total += 1
cmd: Message = await bot.send_message(
- chat_id=chat_id,
- text=f"/fban {user.mention} {reason}",
- disable_web_page_preview=True,
- )
- response: Message | None = await cmd.get_response(
- filters=(FILTERS), timeout=8
+ chat_id=chat_id, text=cmd, disable_web_page_preview=True
)
+ response: Message | None = await cmd.get_response(filters=(FILTERS), timeout=8)
if not response or not (await FBAN_REGEX(bot, response)):
failed.append(fed["name"])
elif "Would you like to update this reason" in response.text:
@@ -107,3 +117,18 @@ async def fed_ban(bot: bot, message: Message):
@bot.add_cmd(cmd="unfban")
async def un_fban(bot: bot, message: Message):
...
+
+
+@bot.add_cmd(cmd="listf")
+async def fed_list(bot: bot, message: Message):
+ output: str = "List of Connected Feds:\n\n"
+ total = 0
+ async for fed in DB.FED_LIST.find():
+ output += f'• {fed["name"]}\n'
+ if "-id" in message.flags:
+ output += f' {fed["_id"]}\n'
+ total += 1
+ if not total:
+ await message.reply("You don't have any Feds Connected.")
+ return
+ await message.reply(output, del_in=30, block=False)