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
Profitroll 5adb004a2a API usage overhaul (#27)
* `/report` command added
* Updated to libbot 1.5
* Moved to [PhotosAPI_Client](https://git.end-play.xyz/profitroll/PhotosAPI_Client) v0.5.0 from using self-made API client
* Video support (almost stable)
* Bug fixes and improvements

Co-authored-by: profitroll <vozhd.kk@gmail.com>
Reviewed-on: #27
2023-06-28 00:57:30 +03:00

43 lines
1.3 KiB
Python

from pyrogram.client import Client
from pyrogram import filters
from pyrogram.types import Message, User
from libbot import sync
from classes.pyroclient import PyroClient
@Client.on_message(
~filters.scheduled
& filters.chat(sync.config_get("comments", "posting"))
& filters.reply
& filters.command(["report"], prefixes=["", "/"])
)
async def command_report(app: PyroClient, msg: Message):
if msg.reply_to_message.forward_from_chat.id == app.config["posting"]["channel"]:
await msg.reply_text(
app._(
"report_sent",
"message",
locale=msg.from_user.language_code
if msg.from_user is not None
else None,
)
)
print(msg)
report_sent = await msg.reply_to_message.forward(app.owner)
sender = msg.from_user if msg.from_user is not None else msg.sender_chat
sender_name = (
sender.first_name if isinstance(sender, User) else sender.title
)
# ACTION NEEDED
# Name and username are somehow None
await report_sent.reply_text(
app._("report_received", "message").format(
sender_name, sender.username, sender.id
),
quote=True,
)