46 lines
1.7 KiB
Python
46 lines
1.7 KiB
Python
|
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
|