This repository has been archived on 2024-08-21. You can view files and clone it, but cannot push or open issues or pull requests.
TelegramPoster/plugins/commands/report.py

45 lines
1.3 KiB
Python
Raw Normal View History

2023-06-28 11:37:18 +03:00
from libbot import sync
from pyrogram import filters
2023-06-28 11:37:18 +03:00
from pyrogram.client import Client
from pyrogram.types import Message, User
2023-06-28 11:37:18 +03:00
from classes.pyroclient import PyroClient
2023-10-15 18:40:56 +03:00
from modules import custom_filters
@Client.on_message(
2023-10-15 18:40:56 +03:00
custom_filters.mode_post
& ~filters.scheduled
& filters.chat(sync.config_get("comments", "posting"))
& filters.reply
& filters.command(["report"], prefixes=["", "/"])
)
2023-10-15 19:14:22 +03:00
async def command_report(app: PyroClient, message: Message):
if (
message.reply_to_message.forward_from_chat.id
!= app.config["posting"]["channel"]
):
2023-06-28 11:37:18 +03:00
return
2023-10-15 19:14:22 +03:00
user = await app.find_user(message.from_user)
2023-06-28 11:37:18 +03:00
2023-10-15 19:14:22 +03:00
await message.reply_text(
2023-06-28 11:37:18 +03:00
app._(
"report_sent",
"message",
2023-10-15 19:14:22 +03:00
locale=user.locale if message.from_user is not None else None,
)
2023-06-28 11:37:18 +03:00
)
2023-10-15 19:14:22 +03:00
report_sent = await message.reply_to_message.forward(app.owner)
sender = message.from_user if message.from_user is not None else message.sender_chat
2023-06-28 11:37:18 +03:00
sender_name = sender.first_name if isinstance(sender, User) else sender.title
2023-06-28 11:37:18 +03:00
await report_sent.reply_text(
app._("report_received", "message", locale=user.locale).format(
sender_name, sender.username, sender.id
),
quote=True,
)