File size: 3,377 Bytes
b6dee3b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/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

@Client.on_callback_query(filters.regex("^unbanch_"))
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)
        
@Client.on_chat_member_updated(filters.chat("RendyProjects"))
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))