WiP-Fbans: Listf and Fbanp.
This commit is contained in:
@@ -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"<b>{data['name']}</b> added to FED LIST.", del_in=5, block=False)
|
||||
await bot.log(text=f"#FBANS\n<b>{data['name']}</b> <code>{message.chat.id}</code> added to FED LIST.")
|
||||
await message.reply(
|
||||
f"<b>{data['name']}</b> added to FED LIST.", del_in=5, block=False
|
||||
)
|
||||
await bot.log(
|
||||
text=f"#FBANS\n<b>{data['name']}</b> <code>{message.chat.id}</code> 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"<b>{name}</b><code>{chat}</code> removed from FED LIST.", del_in=8, block=False
|
||||
f"<b>{name}</b><code>{chat}</code> removed from FED LIST.",
|
||||
del_in=8,
|
||||
block=False,
|
||||
)
|
||||
await bot.log(
|
||||
text=f"#FBANS\n<b>{name}</b><code>{chat}</code> removed from FED LIST."
|
||||
)
|
||||
await bot.log(text=f"#FBANS\n<b>{name}</b><code>{chat}</code> removed from FED LIST.")
|
||||
else:
|
||||
await message.reply(f"<b>{name or chat}</b> 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'<b>• {fed["name"]}</b>\n'
|
||||
if "-id" in message.flags:
|
||||
output += f' <code>{fed["_id"]}</code>\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)
|
||||
|
||||
Reference in New Issue
Block a user