28 lines
927 B
Python
28 lines
927 B
Python
from datetime import datetime
|
|
from app import app
|
|
from pyrogram import filters
|
|
from pyrogram.types import CallbackQuery
|
|
from pyrogram.client import Client
|
|
from modules.utils import locale
|
|
from modules.database import col_warnings
|
|
from bson import ObjectId
|
|
|
|
|
|
@app.on_callback_query(filters.regex("w_rev_[\s\S]*"))
|
|
async def callback_query_warning_revoke(app: Client, clb: CallbackQuery):
|
|
warning = col_warnings.find_one({"_id": ObjectId(str(clb.data).split("_")[2])})
|
|
if warning is None:
|
|
await clb.answer(
|
|
text=locale("warning_not_found", "callback", locale=clb.from_user),
|
|
show_alert=True,
|
|
)
|
|
return
|
|
col_warnings.update_one(
|
|
{"_id": warning["_id"]},
|
|
{"$set": {"active": False, "revoke_date": datetime.now()}},
|
|
)
|
|
await clb.answer(
|
|
text=locale("warning_revoked", "callback", locale=clb.from_user).format(),
|
|
show_alert=True,
|
|
)
|