Spaces:
Running
Running
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# Copyright 2020-2024 (c) Randy W @xtdevs, @xtsea | |
# | |
# from : https://github.com/TeamKillerX | |
# Channel : @RendyProjects | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU Affero General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU Affero General Public License for more details. | |
# | |
# You should have received a copy of the GNU Affero General Public License | |
# along with this program. If not, see <https://www.gnu.org/licenses/>. | |
import time | |
import json | |
import asyncio | |
import io | |
import os | |
import re | |
from pyrogram import * | |
from pyrogram.enums import ChatMemberStatus | |
from pyrogram import enums | |
from pyrogram import Client, filters | |
from pyrogram.types import * | |
from pyrogram.errors import * | |
from database import db | |
from logger import LOGS | |
async def unbanch_usert(client: Client, cb: CallbackQuery): | |
data = cb.data.split("_") | |
user_id = int(data[1]) | |
try: | |
if cb.from_user.id == 1191668125: | |
await client.unban_chat_member( | |
"RendyProjects", | |
user_id, | |
) | |
await cb.edit_message_text( | |
f"you {user_id} have been unbanned from Rendy Projects", | |
disable_web_page_preview=True, | |
) | |
else: | |
await cb.answer("Only Developer", True) | |
except Exception as e: | |
await cb.answer(f"Error: {e}", True) | |
async def auto_banned_ch(client: Client, event: ChatMemberUpdated): | |
if event.old_chat_member and event.old_chat_member.status == ChatMemberStatus.LEFT: | |
try: | |
keyboard_button = InlineKeyboardMarkup( | |
[ | |
[ | |
InlineKeyboardButton( | |
text="⚠️ Unban", | |
callback_data=f"unbanch_{event.from_user.id}" | |
) | |
] | |
] | |
) | |
text_ban = f"User {event.from_user.first_name} was banned from {event.chat.title}." | |
await client.ban_chat_member( | |
event.chat.id, | |
event.from_user.id, | |
) | |
await client.send_message( | |
1191668125, | |
text_ban, | |
reply_markup=keyboard_button | |
) | |
except Exception as e: | |
await client.send_message(1191668125, str(e)) | |
elif event.new_chat_member and event.new_chat_member.status == ChatMemberStatus.MEMBER: | |
try: | |
if await db.is_gbanned(event.from_user.id): | |
text_ban = f"User {event.from_user.first_name} was banned from {event.chat.title}." | |
await client.ban_chat_member( | |
event.chat.id, | |
event.from_user.id, | |
) | |
await client.send_message(1191668125, text_ban) | |
except Exception as e: | |
await client.send_message(1191668125, str(e)) | |