From 2f300f00de4a83bc79c760e3a0926d0125820fd4 Mon Sep 17 00:00:00 2001
From: Forevka <32968153+Forevka@users.noreply.github.com>
Date: Wed, 24 Nov 2021 10:45:47 +0000
Subject: [PATCH] added support for aiogram jail, that was requested by
community
---
.gitignore | 1 +
aiogram_bot/config.py | 2 +
aiogram_bot/handlers/new_chat_members.py | 4 +-
aiogram_bot/handlers/simple_admin.py | 17 ++++++++-
locales/bot.pot | 45 ++++++++++++++---------
locales/en/LC_MESSAGES/bot.po | 43 +++++++++++++++++-----
locales/ru/LC_MESSAGES/bot.po | 47 +++++++++++++++++-------
locales/uk/LC_MESSAGES/bot.po | 47 +++++++++++++++++-------
8 files changed, 149 insertions(+), 57 deletions(-)
diff --git a/.gitignore b/.gitignore
index 7ede749..683a82a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,4 @@ __pycache__
*.mo
.env
+.venv/
\ No newline at end of file
diff --git a/aiogram_bot/config.py b/aiogram_bot/config.py
index 2997c82..1bb58f5 100644
--- a/aiogram_bot/config.py
+++ b/aiogram_bot/config.py
@@ -30,3 +30,5 @@
SUPERUSER_STARTUP_NOTIFIER = env.bool("SUPERUSER_STARTUP_NOTIFIER", default=False)
HASTEBIN_URL = env.str("HASTEBIN_URL", default="https://paste.aiogram.dev")
+
+AIOGRAM_JAIL_LINK = "https://t.me/aiogram_jail"
diff --git a/aiogram_bot/handlers/new_chat_members.py b/aiogram_bot/handlers/new_chat_members.py
index e0fb041..5a3a766 100644
--- a/aiogram_bot/handlers/new_chat_members.py
+++ b/aiogram_bot/handlers/new_chat_members.py
@@ -88,8 +88,8 @@ async def new_chat_member(message: types.Message, chat: Chat):
"{users}, Welcome to the chat. \n"
"Please confirm that you are a human. "
"User filter is enabled in this chat, so if you don't answer my question, "
- "I will be forced to remove you from this chat."
- ).format(users=", ".join(users.values())),
+ "I will be forced to remove you from this chat and you will be imprisoned."
+ ).format(users=", ".join(users.values()), jail_link=config.AIOGRAM_JAIL_LINK),
reply_markup=types.InlineKeyboardMarkup(row_width=3).add(*buttons),
)
await join_list.create_list(
diff --git a/aiogram_bot/handlers/simple_admin.py b/aiogram_bot/handlers/simple_admin.py
index 2970397..9f85db2 100644
--- a/aiogram_bot/handlers/simple_admin.py
+++ b/aiogram_bot/handlers/simple_admin.py
@@ -8,6 +8,7 @@
from aiogram.utils.markdown import hlink, quote_html
from babel.dates import format_timedelta
from loguru import logger
+from aiogram_bot import config
from aiogram_bot.misc import bot, dp, i18n
from aiogram_bot.models.chat import Chat
@@ -44,8 +45,14 @@ async def cmd_ro(message: types.Message, chat: Chat):
return False
await message.reply_to_message.answer(
- _("Read-only activated for user {user}. Duration: {duration}").format(
+ _(
+ "Read-only activated for user {user}. Duration: {duration}\n"
+ "Now you have access to Aiogram Jail, a chat where you can "
+ "tell your opinion about the work of the administrators and it "
+ "will definitely be heard!"
+ ).format(
user=message.reply_to_message.from_user.get_mention(),
+ jail_link=config.AIOGRAM_JAIL_LINK,
duration=format_timedelta(
duration, locale=chat.language, granularity="seconds", format="short"
),
@@ -79,8 +86,14 @@ async def cmd_ban(message: types.Message, chat: Chat):
return False
await message.reply_to_message.answer(
- _("User {user} banned for {duration}").format(
+ _(
+ "User {user} banned for {duration}\n"
+ "Now you have access to Aiogram Jail, a chat where you can "
+ "tell your opinion about the work of the administrators and it "
+ "will definitely be heard!"
+ ).format(
user=message.reply_to_message.from_user.get_mention(),
+ jail_link=config.AIOGRAM_JAIL_LINK,
duration=format_timedelta(
duration, locale=chat.language, granularity="seconds", format="short"
),
diff --git a/locales/bot.pot b/locales/bot.pot
index 0b2915b..436c01e 100644
--- a/locales/bot.pot
+++ b/locales/bot.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: aiogram_bot 0.1\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
-"POT-Creation-Date: 2021-08-22 18:46+0300\n"
+"POT-Creation-Date: 2021-11-24 10:40+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
@@ -20,8 +20,8 @@ msgstr ""
#: aiogram_bot/handlers/base.py:17
msgid ""
"Hello, {user}.\n"
-"Send /help if you want to read my commands list and also you can change language by sending "
-"/settings command.\n"
+"Send /help if you want to read my commands list and also you can change "
+"language by sending /settings command.\n"
"My source code: {source_url}"
msgstr ""
@@ -79,7 +79,8 @@ msgid ""
"{aiogram}"
msgstr ""
-#: aiogram_bot/handlers/chat_settings.py:53 aiogram_bot/handlers/chat_settings.py:95
+#: aiogram_bot/handlers/chat_settings.py:53
+#: aiogram_bot/handlers/chat_settings.py:95
#: aiogram_bot/handlers/chat_settings.py:133
msgid "Invalid chat"
msgstr ""
@@ -88,7 +89,8 @@ msgstr ""
msgid "Choose chat language"
msgstr ""
-#: aiogram_bot/handlers/chat_settings.py:99 aiogram_bot/handlers/chat_settings.py:137
+#: aiogram_bot/handlers/chat_settings.py:99
+#: aiogram_bot/handlers/chat_settings.py:137
msgid "You cannot change settings of this chat!"
msgstr ""
@@ -141,8 +143,9 @@ msgstr ""
#: aiogram_bot/handlers/new_chat_members.py:87
msgid ""
"{users}, Welcome to the chat. \n"
-"Please confirm that you are a human. User filter is enabled in this chat, so if you don't answer"
-" my question, I will be forced to remove you from this chat."
+"Please confirm that you are a human. User filter is enabled in this chat,"
+" so if you don't answer my question, I will be forced to remove you from "
+"this chat and you will be imprisoned."
msgstr ""
#: aiogram_bot/handlers/new_chat_members.py:123
@@ -157,29 +160,37 @@ msgstr ""
msgid "Bad answer."
msgstr ""
-#: aiogram_bot/handlers/simple_admin.py:47
-msgid "Read-only activated for user {user}. Duration: {duration}"
+#: aiogram_bot/handlers/simple_admin.py:48
+msgid ""
+"Read-only activated for user {user}. Duration: {duration}\n"
+"Now you have access to Aiogram Jail, a chat "
+"where you can tell your opinion about the work of the administrators and "
+"it will definitely be heard!"
msgstr ""
-#: aiogram_bot/handlers/simple_admin.py:82
-msgid "User {user} banned for {duration}"
+#: aiogram_bot/handlers/simple_admin.py:89
+msgid ""
+"User {user} banned for {duration}\n"
+"Now you have access to Aiogram Jail, a chat "
+"where you can tell your opinion about the work of the administrators and "
+"it will definitely be heard!"
msgstr ""
-#: aiogram_bot/handlers/simple_admin.py:111
+#: aiogram_bot/handlers/simple_admin.py:124
msgid ""
-"Please use this command is only in reply to message what do you want to report and this message "
-"will be reported to chat administrators."
+"Please use this command is only in reply to message what do you want to "
+"report and this message will be reported to chat administrators."
msgstr ""
-#: aiogram_bot/handlers/simple_admin.py:118
+#: aiogram_bot/handlers/simple_admin.py:131
msgid "[ALERT] User {user} is reported message in chat {chat}."
msgstr ""
-#: aiogram_bot/handlers/simple_admin.py:140
+#: aiogram_bot/handlers/simple_admin.py:153
msgid "This message is reported to chat administrators."
msgstr ""
-#: aiogram_bot/handlers/simple_admin.py:152
+#: aiogram_bot/handlers/simple_admin.py:165
msgid "User {user} leave this chat..."
msgstr ""
diff --git a/locales/en/LC_MESSAGES/bot.po b/locales/en/LC_MESSAGES/bot.po
index df1ef81..b2fc511 100644
--- a/locales/en/LC_MESSAGES/bot.po
+++ b/locales/en/LC_MESSAGES/bot.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: aiogram_bot 0.1\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
-"POT-Creation-Date: 2021-08-22 18:46+0300\n"
+"POT-Creation-Date: 2021-11-24 10:40+0000\n"
"PO-Revision-Date: 2019-10-22 00:12+0300\n"
"Last-Translator: \n"
"Language: en\n"
@@ -147,7 +147,7 @@ msgid ""
"{users}, Welcome to the chat. \n"
"Please confirm that you are a human. User filter is enabled in this chat,"
" so if you don't answer my question, I will be forced to remove you from "
-"this chat."
+"this chat and you will be imprisoned."
msgstr ""
#: aiogram_bot/handlers/new_chat_members.py:123
@@ -162,29 +162,37 @@ msgstr ""
msgid "Bad answer."
msgstr ""
-#: aiogram_bot/handlers/simple_admin.py:47
-msgid "Read-only activated for user {user}. Duration: {duration}"
+#: aiogram_bot/handlers/simple_admin.py:48
+msgid ""
+"Read-only activated for user {user}. Duration: {duration}\n"
+"Now you have access to Aiogram Jail, a chat "
+"where you can tell your opinion about the work of the administrators and "
+"it will definitely be heard!"
msgstr ""
-#: aiogram_bot/handlers/simple_admin.py:82
-msgid "User {user} banned for {duration}"
+#: aiogram_bot/handlers/simple_admin.py:89
+msgid ""
+"User {user} banned for {duration}\n"
+"Now you have access to Aiogram Jail, a chat "
+"where you can tell your opinion about the work of the administrators and "
+"it will definitely be heard!"
msgstr ""
-#: aiogram_bot/handlers/simple_admin.py:111
+#: aiogram_bot/handlers/simple_admin.py:124
msgid ""
"Please use this command is only in reply to message what do you want to "
"report and this message will be reported to chat administrators."
msgstr ""
-#: aiogram_bot/handlers/simple_admin.py:118
+#: aiogram_bot/handlers/simple_admin.py:131
msgid "[ALERT] User {user} is reported message in chat {chat}."
msgstr "🔥🔥🔥 User {user} is reported message in chat {chat}."
-#: aiogram_bot/handlers/simple_admin.py:140
+#: aiogram_bot/handlers/simple_admin.py:153
msgid "This message is reported to chat administrators."
msgstr ""
-#: aiogram_bot/handlers/simple_admin.py:152
+#: aiogram_bot/handlers/simple_admin.py:165
msgid "User {user} leave this chat..."
msgstr ""
@@ -220,3 +228,18 @@ msgstr ""
msgid "{status} Do not disturb"
msgstr ""
+#~ msgid ""
+#~ "{users}, Welcome to the chat. \n"
+#~ "Please confirm that you are a "
+#~ "human. User filter is enabled in "
+#~ "this chat, so if you don't answer"
+#~ " my question, I will be forced "
+#~ "to remove you from this chat."
+#~ msgstr ""
+
+#~ msgid "Read-only activated for user {user}. Duration: {duration}"
+#~ msgstr ""
+
+#~ msgid "User {user} banned for {duration}"
+#~ msgstr ""
+
diff --git a/locales/ru/LC_MESSAGES/bot.po b/locales/ru/LC_MESSAGES/bot.po
index a229b83..c066318 100644
--- a/locales/ru/LC_MESSAGES/bot.po
+++ b/locales/ru/LC_MESSAGES/bot.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: aiogram_bot 0.1\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
-"POT-Creation-Date: 2021-08-22 18:46+0300\n"
+"POT-Creation-Date: 2021-11-24 10:40+0000\n"
"PO-Revision-Date: 2019-11-06 11:40+0200\n"
"Last-Translator: \n"
"Language: ru\n"
@@ -153,16 +153,17 @@ msgid "I'm human"
msgstr "Я человек"
#: aiogram_bot/handlers/new_chat_members.py:87
+#, fuzzy
msgid ""
"{users}, Welcome to the chat. \n"
"Please confirm that you are a human. User filter is enabled in this chat,"
" so if you don't answer my question, I will be forced to remove you from "
-"this chat."
+"this chat and you will be imprisoned."
msgstr ""
"Привет, {users}!\n"
"Пожалуйста подтверди, что ты человек. В этом чате включен фильтр новых "
"пользователей, поэтому, если ты не ответишь на мой вопрос, я буду "
-"вынужден прогнать тебя из чата."
+"вынужден прогнать тебя из чата и отправить в тюрьму."
#: aiogram_bot/handlers/new_chat_members.py:123
msgid "This message is not for you!"
@@ -176,15 +177,29 @@ msgstr "Хороший ответ!"
msgid "Bad answer."
msgstr "Плохой ответ."
-#: aiogram_bot/handlers/simple_admin.py:47
-msgid "Read-only activated for user {user}. Duration: {duration}"
-msgstr "Пользователь {user} помещен в RO на {duration}"
+#: aiogram_bot/handlers/simple_admin.py:48
+msgid ""
+"Read-only activated for user {user}. Duration: {duration}\n"
+"Now you have access to Aiogram Jail, a chat "
+"where you can tell your opinion about the work of the administrators and "
+"it will definitely be heard!"
+msgstr ""
+"Пользователь {user} помещен в RO на {duration}\n"
+"Теперь вам открыт доступ к Aiogram Jail, чат где вы можете "
+"высказать своё мнение о работе администраторов и оно будет обязательно услышано!"
-#: aiogram_bot/handlers/simple_admin.py:82
-msgid "User {user} banned for {duration}"
-msgstr "Пользователь {user} забанен на {duration}"
+#: aiogram_bot/handlers/simple_admin.py:89
+msgid ""
+"User {user} banned for {duration}\n"
+"Now you have access to Aiogram Jail, a chat "
+"where you can tell your opinion about the work of the administrators and "
+"it will definitely be heard!"
+msgstr ""
+"Пользователь {user} забанен на {duration}\n"
+"Теперь вам открыт доступ к Aiogram Jail, чат где вы можете "
+"высказать своё мнение о работе администраторов и оно будет обязательно услышано!"
-#: aiogram_bot/handlers/simple_admin.py:111
+#: aiogram_bot/handlers/simple_admin.py:124
msgid ""
"Please use this command is only in reply to message what do you want to "
"report and this message will be reported to chat administrators."
@@ -192,15 +207,15 @@ msgstr ""
"Пожалуйста, используй эту команду только в ответ на другое сообщение и я "
"сообщу про него администрации чата."
-#: aiogram_bot/handlers/simple_admin.py:118
+#: aiogram_bot/handlers/simple_admin.py:131
msgid "[ALERT] User {user} is reported message in chat {chat}."
msgstr "🔥 Пользователь {user} сообщает про сообщение в чате {chat}."
-#: aiogram_bot/handlers/simple_admin.py:140
+#: aiogram_bot/handlers/simple_admin.py:153
msgid "This message is reported to chat administrators."
msgstr "Я сообщил про это сообщение администрации чата."
-#: aiogram_bot/handlers/simple_admin.py:152
+#: aiogram_bot/handlers/simple_admin.py:165
msgid "User {user} leave this chat..."
msgstr "Пользователь {user} покинул этот чат..."
@@ -240,3 +255,9 @@ msgstr "Персональные настройки"
msgid "{status} Do not disturb"
msgstr "{status} Не беспокоить"
+#~ msgid "Read-only activated for user {user}. Duration: {duration}"
+#~ msgstr "Пользователь {user} помещен в RO на {duration}"
+
+#~ msgid "User {user} banned for {duration}"
+#~ msgstr "Пользователь {user} забанен на {duration}"
+
diff --git a/locales/uk/LC_MESSAGES/bot.po b/locales/uk/LC_MESSAGES/bot.po
index 8c8f876..f63a898 100644
--- a/locales/uk/LC_MESSAGES/bot.po
+++ b/locales/uk/LC_MESSAGES/bot.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: aiogram_bot 0.1\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
-"POT-Creation-Date: 2021-08-22 18:46+0300\n"
+"POT-Creation-Date: 2021-11-24 10:40+0000\n"
"PO-Revision-Date: 2019-11-06 11:41+0200\n"
"Last-Translator: \n"
"Language: uk\n"
@@ -153,16 +153,17 @@ msgid "I'm human"
msgstr "Я людина"
#: aiogram_bot/handlers/new_chat_members.py:87
+#, fuzzy
msgid ""
"{users}, Welcome to the chat. \n"
"Please confirm that you are a human. User filter is enabled in this chat,"
" so if you don't answer my question, I will be forced to remove you from "
-"this chat."
+"this chat and you will be imprisoned."
msgstr ""
"Вітаю, {users}.\n"
"Будь ласка, підтверди що ти людина. В цьому чаті ввімкнуто фільтр нових "
"користувачів, отже, якщо ти не дасиш відповідь на моє запитання, я буду "
-"змушений вигнати тебе з чату."
+"змушений вигнати тебе з чату і відправити в тюрьму."
#: aiogram_bot/handlers/new_chat_members.py:123
msgid "This message is not for you!"
@@ -176,15 +177,29 @@ msgstr "Гарна відповідь!"
msgid "Bad answer."
msgstr "Погана відповідь."
-#: aiogram_bot/handlers/simple_admin.py:47
-msgid "Read-only activated for user {user}. Duration: {duration}"
-msgstr "Користувачу {user} заборонено писати в чаті на {duration}"
+#: aiogram_bot/handlers/simple_admin.py:48
+msgid ""
+"Read-only activated for user {user}. Duration: {duration}\n"
+"Now you have access to Aiogram Jail, a chat "
+"where you can tell your opinion about the work of the administrators and "
+"it will definitely be heard!"
+msgstr ""
+"Користувачу {user} заборонено писати в чаті на {duration}\n"
+"Тепер вам відкритий доступ до Aiogram Jail "
+"чат де ви можете висловитись про роботу адміністрації і вас буде точно почуто!"
-#: aiogram_bot/handlers/simple_admin.py:82
-msgid "User {user} banned for {duration}"
-msgstr "Користувача {user} заблоковано на {duration}"
+#: aiogram_bot/handlers/simple_admin.py:89
+msgid ""
+"User {user} banned for {duration}\n"
+"Now you have access to Aiogram Jail, a chat "
+"where you can tell your opinion about the work of the administrators and "
+"it will definitely be heard!"
+msgstr ""
+"Користувача {user} заблоковано на {duration}"
+"Тепер вам відкритий доступ до Aiogram Jail "
+"чат де ви можете висловитись про роботу адміністрації і вас буде точно почуто!"
-#: aiogram_bot/handlers/simple_admin.py:111
+#: aiogram_bot/handlers/simple_admin.py:124
msgid ""
"Please use this command is only in reply to message what do you want to "
"report and this message will be reported to chat administrators."
@@ -192,15 +207,15 @@ msgstr ""
"Будь ласка, використовуй дану команду тільки у відповідь на інше "
"повідомлення і я повідомлю про нього адміністрації чату."
-#: aiogram_bot/handlers/simple_admin.py:118
+#: aiogram_bot/handlers/simple_admin.py:131
msgid "[ALERT] User {user} is reported message in chat {chat}."
msgstr "🔥 Користувач {user} кличе адміністрацію в чаті {chat}."
-#: aiogram_bot/handlers/simple_admin.py:140
+#: aiogram_bot/handlers/simple_admin.py:153
msgid "This message is reported to chat administrators."
msgstr "Я повідомим адміністрацію чату про це повідомлення."
-#: aiogram_bot/handlers/simple_admin.py:152
+#: aiogram_bot/handlers/simple_admin.py:165
msgid "User {user} leave this chat..."
msgstr "Користувач {user} покинув цей чат..."
@@ -236,3 +251,9 @@ msgstr "Персональні налаштування"
msgid "{status} Do not disturb"
msgstr "{status} Не турбувати"
+#~ msgid "Read-only activated for user {user}. Duration: {duration}"
+#~ msgstr "Користувачу {user} заборонено писати в чаті на {duration}"
+
+#~ msgid "User {user} banned for {duration}"
+#~ msgstr "Користувача {user} заблоковано на {duration}"
+