This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
Telegram/modules/handlers/group_message.py

46 lines
1.7 KiB
Python
Raw Normal View History

2023-04-05 23:31:07 +03:00
from datetime import datetime
from app import app
from pyrogram import filters
from pyrogram.types import Message
from pyrogram.client import Client
from modules.logging import logWrite
from modules.utils import configGet, locale
from modules.database import col_warnings
from modules import custom_filters
from polyglot.detect import Detector
@app.on_message(
custom_filters.enabled_general
& ~filters.scheduled
& filters.chat(configGet("users", "groups"))
)
async def msg_destination_group(app: Client, msg: Message):
if msg.text is not None:
lang = Detector(msg.text, quiet=True).language
if lang.code == "ru":
logWrite(
f"Message '{msg.text}' from {msg.from_user.first_name} ({msg.from_user.id}) is fucking russian!!! [confidence {lang.confidence}]"
)
else:
logWrite(
f"Message '{msg.text}' from {msg.from_user.first_name} ({msg.from_user.id}) is written {lang.code} [confidence {lang.confidence}]"
)
return
elif msg.caption is not None:
lang = Detector(msg.caption, quiet=True).language
if lang.code == "ru":
logWrite(
f"Message '{msg.caption}' from {msg.from_user.first_name} ({msg.from_user.id}) is fucking russian!!! [confidence {lang.confidence}]"
)
else:
logWrite(
f"Message '{msg.caption}' from {msg.from_user.first_name} ({msg.from_user.id}) is written {lang.code} [confidence {lang.confidence}]"
)
return
else:
logWrite(
f"Message from {msg.from_user.first_name} ({msg.from_user.id}) has no text in it."
)
return