Skip to content

Commit

Permalink
better languages for moderation
Browse files Browse the repository at this point in the history
  • Loading branch information
ohld committed Jun 9, 2024
1 parent 673c5af commit 708cc4e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
8 changes: 8 additions & 0 deletions src/tgbot/handlers/upload/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
SUPPORTED_LANGUAGES = {
"ru": "🇷🇺 Русский",
"uk": "🇺🇦 Українська",
"en": "🇺🇸 English 🇬🇧",
"es": "🇪🇸 Español",
"ar": "🇸🇦 العربية",
"uz": "🇺🇿 O'zbekcha",
}
4 changes: 3 additions & 1 deletion src/tgbot/handlers/upload/moderation.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
update_meme_by_upload_id,
)
from src.tgbot.user_info import get_user_info
from src.tgbot.handlers.upload.constants import SUPPORTED_LANGUAGES

UPLOADED_MEME_REIVIEW_CALLBACK_DATA_PATTERN = "upload:{upload_id}:review:{action}"
UPLOADED_MEME_REVIEW_CALLBACK_DATA_REGEXP = r"upload:(\d+):review:(\w+)"
Expand Down Expand Up @@ -152,11 +153,12 @@ async def send_uploaded_meme_to_manual_review(
meme_upload: dict[str, Any],
bot: Bot,
) -> None:
meme_lang = SUPPORTED_LANGUAGES.get(meme["language_code"]) or meme["language_code"]
text = f"""
👨‍✈️ REVIEW MEME #{meme["id"]}
<b>Upload Id</b>: {meme_upload["id"]}
<b>Uploaded by</b>: #{meme_upload["user_id"]}
<b>Language code</b>: {meme["language_code"]}
<b>Language code</b>: {meme_lang}
"""

if meme_upload["forward_origin"]:
Expand Down
12 changes: 2 additions & 10 deletions src/tgbot/handlers/upload/upload_meme.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from src import localizer
from src.recommendations.meme_queue import check_queue
from src.tgbot.handlers.upload.constants import SUPPORTED_LANGUAGES
from src.tgbot.handlers.upload.moderation import uploaded_meme_auto_review
from src.tgbot.handlers.upload.service import (
count_24h_uploaded_not_approved_memes,
Expand All @@ -28,15 +29,6 @@
get_related_channel_link,
)

LANGUAGES = {
"ru": "🇷🇺 Русский",
"uk": "🇺🇦 Українська",
"en": "🇺🇸 English 🇬🇧",
"es": "🇪🇸 Español",
"ar": "🇸🇦 العربية",
"uz": "🇺🇿 O'zbekcha",
}

RULES_ACCEPTED_CALLBACK_DATA_PATTERN = "upload:{upload_id}:rules:accepted"
RULES_ACCEPTED_CALLBACK_DATA_REGEXP = r"upload:(\d+):rules:accepted"

Expand All @@ -49,7 +41,7 @@

def get_meme_language_selector_keyboard(upload_id: int) -> list[list[dict]]:
all_lang_buttons = []
for lang, lang_text in LANGUAGES.items():
for lang, lang_text in SUPPORTED_LANGUAGES.items():
button_text = lang_text or lang

all_lang_buttons.append(
Expand Down

0 comments on commit 708cc4e

Please sign in to comment.