|
@@ -23,9 +23,11 @@ SOFTWARE.
|
|
|
"""
|
|
"""
|
|
|
from pyrogram import filters
|
|
from pyrogram import filters
|
|
|
from pyrogram.types import (
|
|
from pyrogram.types import (
|
|
|
- Message, CallbackQuery,
|
|
|
|
|
- InlineKeyboardMarkup, InlineKeyboardButton
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ Message,
|
|
|
|
|
+ CallbackQuery,
|
|
|
|
|
+ InlineKeyboardMarkup,
|
|
|
|
|
+ InlineKeyboardButton,
|
|
|
|
|
+)
|
|
|
|
|
|
|
|
from wbb import app, arq, SUDOERS, LOG_GROUP_ID
|
|
from wbb import app, arq, SUDOERS, LOG_GROUP_ID
|
|
|
from wbb.core.decorators.errors import capture_err
|
|
from wbb.core.decorators.errors import capture_err
|
|
@@ -54,10 +56,8 @@ __HELP__ = """
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.on_message(
|
|
@app.on_message(
|
|
|
- (filters.text | filters.caption)
|
|
|
|
|
- & ~filters.private
|
|
|
|
|
- & ~filters.me,
|
|
|
|
|
- group=spam_protection_group
|
|
|
|
|
|
|
+ (filters.text | filters.caption) & ~filters.private & ~filters.me,
|
|
|
|
|
+ group=spam_protection_group,
|
|
|
)
|
|
)
|
|
|
async def spam_protection_func(_, message: Message):
|
|
async def spam_protection_func(_, message: Message):
|
|
|
text = message.text if message.text else message.caption
|
|
text = message.text if message.text else message.caption
|
|
@@ -85,29 +85,31 @@ async def spam_protection_func(_, message: Message):
|
|
|
**Action:** Alerted
|
|
**Action:** Alerted
|
|
|
"""
|
|
"""
|
|
|
keyboard = InlineKeyboardMarkup(
|
|
keyboard = InlineKeyboardMarkup(
|
|
|
|
|
+ [
|
|
|
[
|
|
[
|
|
|
- [
|
|
|
|
|
- InlineKeyboardButton(
|
|
|
|
|
- text="Yes it's spam",
|
|
|
|
|
- callback_data="s_p_spam"
|
|
|
|
|
- )
|
|
|
|
|
- ],
|
|
|
|
|
- [
|
|
|
|
|
- InlineKeyboardButton(
|
|
|
|
|
- text="No, it's not spam",
|
|
|
|
|
- callback_data="s_p_ham",
|
|
|
|
|
- )
|
|
|
|
|
- ]
|
|
|
|
|
- ]
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ InlineKeyboardButton(
|
|
|
|
|
+ text="Yes it's spam", callback_data="s_p_spam"
|
|
|
|
|
+ )
|
|
|
|
|
+ ],
|
|
|
|
|
+ [
|
|
|
|
|
+ InlineKeyboardButton(
|
|
|
|
|
+ text="No, it's not spam",
|
|
|
|
|
+ callback_data="s_p_ham",
|
|
|
|
|
+ )
|
|
|
|
|
+ ],
|
|
|
|
|
+ ]
|
|
|
|
|
+ )
|
|
|
await message.reply_text(
|
|
await message.reply_text(
|
|
|
- text=text,
|
|
|
|
|
- reply_markup=keyboard,
|
|
|
|
|
- disable_web_page_preview=True,
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ text=text,
|
|
|
|
|
+ reply_markup=keyboard,
|
|
|
|
|
+ disable_web_page_preview=True,
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
|
|
|
-dev_forward = "If you're not a developer of WBB, forward this message to devs, " \
|
|
|
|
|
- + "so that they can use it to improve spam protection algorithm."
|
|
|
|
|
|
|
+dev_forward = (
|
|
|
|
|
+ "If you're not a developer of WBB, forward this message to devs, "
|
|
|
|
|
+ + "so that they can use it to improve spam protection algorithm."
|
|
|
|
|
+)
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.on_callback_query(filters.regex("s_p_"))
|
|
@app.on_callback_query(filters.regex("s_p_"))
|
|
@@ -119,10 +121,10 @@ async def spam_p_callback(_, cq: CallbackQuery):
|
|
|
permission = "can_delete_messages"
|
|
permission = "can_delete_messages"
|
|
|
if permission not in permissions:
|
|
if permission not in permissions:
|
|
|
return await cq.answer(
|
|
return await cq.answer(
|
|
|
- "You don't have enough permissions to perform this action.\n"
|
|
|
|
|
- + f"Permission needed: {permission}",
|
|
|
|
|
- show_alert=True,
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ "You don't have enough permissions to perform this action.\n"
|
|
|
|
|
+ + f"Permission needed: {permission}",
|
|
|
|
|
+ show_alert=True,
|
|
|
|
|
+ )
|
|
|
|
|
|
|
|
if cq.data.split("_")[-1] == "spam":
|
|
if cq.data.split("_")[-1] == "spam":
|
|
|
try:
|
|
try:
|
|
@@ -131,29 +133,39 @@ async def spam_p_callback(_, cq: CallbackQuery):
|
|
|
await cq.message.delete()
|
|
await cq.message.delete()
|
|
|
return
|
|
return
|
|
|
text = cq.message.text.markdown
|
|
text = cq.message.text.markdown
|
|
|
- text = text.replace("Alerted", f"Deleted Message With {from_user.mention}'s Approval.")
|
|
|
|
|
|
|
+ text = text.replace(
|
|
|
|
|
+ "Alerted", f"Deleted Message With {from_user.mention}'s Approval."
|
|
|
|
|
+ )
|
|
|
return await cq.message.edit(text)
|
|
return await cq.message.edit(text)
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
await cq.message.delete()
|
|
await cq.message.delete()
|
|
|
if cq.message.reply_to_message:
|
|
if cq.message.reply_to_message:
|
|
|
text = f"**ADMINS OF {chat_id} FLAGGED THIS MESSAGE AS SPAM**\n\n"
|
|
text = f"**ADMINS OF {chat_id} FLAGGED THIS MESSAGE AS SPAM**\n\n"
|
|
|
text += f"`{cq.message.reply_to_message.text.markdown}`\n\n__{dev_forward}__"
|
|
text += f"`{cq.message.reply_to_message.text.markdown}`\n\n__{dev_forward}__"
|
|
|
- return await app.send_message(LOG_GROUP_ID, text, disable_web_page_preview=True)
|
|
|
|
|
|
|
+ return await app.send_message(
|
|
|
|
|
+ LOG_GROUP_ID, text, disable_web_page_preview=True
|
|
|
|
|
+ )
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.on_message(filters.command("spam") & ~filters.private)
|
|
@app.on_message(filters.command("spam") & ~filters.private)
|
|
|
async def spam_flag_func(_, message: Message):
|
|
async def spam_flag_func(_, message: Message):
|
|
|
if not message.reply_to_message:
|
|
if not message.reply_to_message:
|
|
|
- return await message.reply_text("Reply to a message to flag it as spam")
|
|
|
|
|
-
|
|
|
|
|
|
|
+ return await message.reply_text(
|
|
|
|
|
+ "Reply to a message to flag it as spam"
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
r = message.reply_to_message
|
|
r = message.reply_to_message
|
|
|
if not r.text and not r.caption:
|
|
if not r.text and not r.caption:
|
|
|
- return await message.reply_text("Reply to a text message to flag it as spam")
|
|
|
|
|
|
|
+ return await message.reply_text(
|
|
|
|
|
+ "Reply to a text message to flag it as spam"
|
|
|
|
|
+ )
|
|
|
|
|
|
|
|
text = r.text or r.caption
|
|
text = r.text or r.caption
|
|
|
if not text:
|
|
if not text:
|
|
|
- return await message.reply_text("Reply to a text message to flag it as spam")
|
|
|
|
|
-
|
|
|
|
|
|
|
+ return await message.reply_text(
|
|
|
|
|
+ "Reply to a text message to flag it as spam"
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
msg = f"""
|
|
msg = f"""
|
|
|
**ADMINS OF {message.chat.id} FLAGGED THIS MESSAGE AS SPAM**
|
|
**ADMINS OF {message.chat.id} FLAGGED THIS MESSAGE AS SPAM**
|
|
|
|
|
|
|
@@ -164,6 +176,6 @@ async def spam_flag_func(_, message: Message):
|
|
|
__{dev_forward}__
|
|
__{dev_forward}__
|
|
|
"""
|
|
"""
|
|
|
await message.reply_text(
|
|
await message.reply_text(
|
|
|
- "Message was flagged as spam, Devs will use this to improve spam protection algorithm."
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ "Message was flagged as spam, Devs will use it to improve spam protection algorithm."
|
|
|
|
|
+ )
|
|
|
await app.send_message(LOG_GROUP_ID, msg, disable_web_page_preview=True)
|
|
await app.send_message(LOG_GROUP_ID, msg, disable_web_page_preview=True)
|