WIP: /report command

This commit is contained in:
Profitroll 2023-06-26 23:02:38 +02:00
parent adc7228a71
commit eb78a75a88
Signed by: profitroll
GPG Key ID: FA35CAB49DACD3B2
5 changed files with 46 additions and 2 deletions

View File

@ -46,6 +46,7 @@
"disabled_plugins": [],
"posting": {
"channel": 0,
"comments": 0,
"silent": false,
"move_sent": false,
"use_interval": false,
@ -142,6 +143,14 @@
}
]
},
"report": {
"scopes": [
{
"name": "BotCommandScopeChat",
"chat_id": "comments"
}
]
},
"forwards": {
"scopes": [
{

View File

@ -60,7 +60,9 @@
"remove_success": "Removed media with ID `{0}`.",
"remove_failure": "Could not remove media with ID `{0}`. Check if provided ID is correct and if it is - you can also check bot's log for details.",
"update_available": "**New version found**\nThere's a newer version of a bot found. You can update your bot to [{0}]({1}) using command line of your host.\n\n**Release notes**\n{2}\n\nRead more about updating you bot on the [wiki page](https://git.end-play.xyz/profitroll/TelegramPoster/wiki/Updating-Instance).\n\nPlease not that you can also disable this notification by editing `reports.update` key of the config.",
"shutdown_confirm": "There are {0} unfinished users' contexts. If you turn off the bot, those will be lost. Please confirm shutdown using a button below."
"shutdown_confirm": "There are {0} unfinished users' contexts. If you turn off the bot, those will be lost. Please confirm shutdown using a button below.",
"report_sent": "We've notified admins about presumable violation. Thank you for cooperation.",
"report_received": "This message has been reported by {0} (@{1}, `{2}`)"
},
"button": {
"sub_yes": "✅ Accept",

View File

@ -60,7 +60,9 @@
"remove_success": "Видалено медіа з ID `{0}`.",
"remove_failure": "Не вдалося видалити медіа з ID `{0}`. Перевірте, чи вказано правильний ID, і якщо він правильний, ви також можете переглянути логи бота для отримання більш детальної інформації.",
"update_available": "**Знайдено нову версію**\nЗнайдено нову версію бота. Ви можете оновити бота до [{0}]({1}) за допомогою командного рядка вашого хосту.\n\n**Примітки до релізу**\n{2}\n\nДетальніше про оновлення бота можна знайти на [вікі-сторінці](https://git.end-play.xyz/profitroll/TelegramPoster/wiki/Updating-Instance).\n\nЗверніть увагу, що ви також можете вимкнути це сповіщення, відредагувавши ключ `reports.update` у конфігурації.",
"shutdown_confirm": "Існує {0} незавершених контекстів користувачів. Якщо ви вимкнете бота, вони будуть втрачені. Будь ласка, підтвердіть вимкнення за допомогою кнопки нижче."
"shutdown_confirm": "Існує {0} незавершених контекстів користувачів. Якщо ви вимкнете бота, вони будуть втрачені. Будь ласка, підтвердіть вимкнення за допомогою кнопки нижче.",
"report_sent": "Ми повідомили адміністрацію про потенційне порушення. Дякую за співпрацю.",
"report_received": "На це повідомлення було отримано скаргу від {0} (@{1}, `{2}`)"
},
"button": {
"sub_yes": "✅ Прийняти",

View File

@ -0,0 +1,28 @@
from pyrogram.client import Client
from pyrogram import filters
from pyrogram.types import Message
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_send", "message", locale=msg.from_user.language_code))
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 hasattr(sender, "first_name") 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,
)

View File

@ -29,6 +29,9 @@ logger = logging.getLogger(__name__)
async def get_submission(app: PyroClient, msg: Message):
global USERS_WITH_CONTEXT
if not hasattr(msg.from_user, "id"):
return
if msg.from_user.id in USERS_WITH_CONTEXT:
return