MissKatyPyro/misskaty/plugins/auto_approve.py
deepsource-autofix[bot] 0dbab68a39
Format code with black and isort (#9)
This commit fixes the style issues introduced in 95ecce1 according to the output
from black and isort.

Details: https://deepsource.io/gh/yasirarism/MissKatyPyro/transform/2b5c318f-57d7-4419-8e76-1d6c31d72999/

Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2023-01-10 20:20:35 +07:00

71 lines
2.4 KiB
Python

"""
* @author yasir <yasiramunandar@gmail.com>
* @date 2022-12-01 09:12:27
* @lastModified 2022-12-01 09:32:31
* @projectName MissKatyPyro
* Copyright @YasirPedia All rights reserved
"""
from pyrogram import filters
from pyrogram.errors import UserAlreadyParticipant, UserIsBlocked
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
from misskaty import app
from misskaty.core.decorator.errors import capture_err
@capture_err
@app.on_chat_join_request(filters.chat(-1001686184174))
async def approve_join_chat(c, m):
try:
markup = InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="Sudah", callback_data=f"approve_{m.chat.id}"
),
InlineKeyboardButton(
text="Belum", callback_data=f"declined_{m.chat.id}"
),
]
]
)
await c.send_message(
m.from_user.id,
"<b>PERMINTAAN JOIN CHANNEL YMOVIEZ REBORN</b>\n\nSebelum masuk ke channel ada tes kejujuran, apakah anda sudah membaca catatan di @YMovieZ_New? Jika sudah silahkan klik <b>Sudah</b>, jika kamu berbohong resiko kamu tanggung sendiri 😶‍🌫️.\n\nBot by @YasirPediaChannel",
disable_web_page_preview=True,
reply_markup=markup,
)
except UserIsBlocked:
await m.decline()
@app.on_callback_query(filters.regex(r"^approve"))
async def approve_chat(c, q):
i, chat = q.data.split("_")
try:
await q.message.edit(
"Yeayy, selamat kamu bisa bergabung di Channel YMovieZ Reborn..."
)
await c.approve_chat_join_request(chat, q.from_user.id)
except UserAlreadyParticipant:
await q.message.edit(
"Kamu sudah di acc join grup, jadi ga perlu menekan button."
)
except Exception as err:
await q.message.edit(err)
@app.on_callback_query(filters.regex(r"^declined"))
async def decline_chat(c, q):
i, chat = q.data.split("_")
try:
await q.message.edit(
"Yahh, kamu ditolak join channel. Biasakan rajin membaca yahhh.."
)
await c.decline_chat_join_request(chat, q.from_user.id)
except UserAlreadyParticipant:
await q.message.edit(
"Kamu sudah di acc join grup, jadi ga perlu menekan button."
)
except Exception as err:
await q.message.edit(err)