randydev commited on
Commit
b4f595d
·
verified ·
1 Parent(s): 25c5f41

Delete chatbot/plugins/autobanch.py

Browse files
Files changed (1) hide show
  1. chatbot/plugins/autobanch.py +0 -114
chatbot/plugins/autobanch.py DELETED
@@ -1,114 +0,0 @@
1
- #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
- # Copyright 2020-2024 (c) Randy W @xtdevs, @xtsea
4
- #
5
- # from : https://github.com/TeamKillerX
6
- # Channel : @RendyProjects
7
- # This program is free software: you can redistribute it and/or modify
8
- # it under the terms of the GNU Affero General Public License as published by
9
- # the Free Software Foundation, either version 3 of the License, or
10
- # (at your option) any later version.
11
- #
12
- # This program is distributed in the hope that it will be useful,
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- # GNU Affero General Public License for more details.
16
- #
17
- # You should have received a copy of the GNU Affero General Public License
18
- # along with this program. If not, see <https://www.gnu.org/licenses/>.
19
-
20
- import time
21
- import json
22
- import asyncio
23
- import io
24
- import os
25
- import re
26
- import logging
27
-
28
- from pyrogram import *
29
- from pyrogram.enums import ChatMemberStatus, ChatType
30
- from pyrogram import enums
31
- from pyrogram import Client, filters
32
- from pyrogram.types import *
33
- from pyrogram.errors import *
34
- from database import db
35
- from logger import LOGS
36
-
37
- logging.basicConfig(level=logging.INFO)
38
- logger = logging.getLogger(__name__)
39
-
40
- @Client.on_callback_query(filters.regex("^unbanch_"))
41
- async def unbanch_usert(client: Client, cb: CallbackQuery):
42
- data = cb.data.split("_")
43
- if len(data) != 2:
44
- await cb.answer("Invalid data format.", True)
45
- return
46
- try:
47
- user_id = int(data[1])
48
- except ValueError:
49
- await cb.answer("Invalid user ID.", True)
50
- return
51
- try:
52
- if cb.from_user.id == 1191668125:
53
- await client.unban_chat_member(
54
- "RendyProjects",
55
- user_id,
56
- )
57
- await cb.edit_message_text(
58
- f"User {user_id} has been unbanned from Rendy Projects.",
59
- disable_web_page_preview=True,
60
- )
61
- logger.info(f"User {user_id} has been unbanned by admin {cb.from_user.id}.")
62
- else:
63
- await cb.answer("Only the Developer can perform this action.", True)
64
- logger.warning(f"Unauthorized unban attempt by user {cb.from_user.id}.")
65
- except Exception as e:
66
- await cb.answer(f"Error: {e}", True)
67
- logger.error(f"Error unbanning user {user_id}: {e}")
68
-
69
- def create_button_unban(user_id):
70
- return InlineKeyboardMarkup(
71
- [[InlineKeyboardButton(
72
- text="⚠️ Unban", callback_data=f"unbanch_{user_id}")]]
73
- )
74
-
75
- @Client.on_chat_member_updated(
76
- filters.chat("RendyProjects")
77
- )
78
- async def auto_banned_ch(client: Client, event: ChatMemberUpdated):
79
- logger.info(f"Chat member update: {event}")
80
- old_status = event.old_chat_member.status if event.old_chat_member else None
81
- new_status = event.new_chat_member.status if event.new_chat_member else None
82
- member = await client.get_chat_member(event.chat.id, event.from_user.id)
83
-
84
- if member.status == ChatMemberStatus.LEFT:
85
- if event.chat.type == ChatType.CHANNEL:
86
- try:
87
- text_ban = f"User {event.from_user.first_name} (ID: {event.from_user.id}) was banned from {event.chat.title}."
88
- await client.ban_chat_member(
89
- event.chat.id,
90
- event.from_user.id,
91
- )
92
- await client.send_message(
93
- "KillerXSupport",
94
- text_ban,
95
- reply_markup=create_button_unban(event.from_user.id)
96
- )
97
- logger.info(f"User {event.from_user.id} has been banned for leaving the chat.")
98
- except Exception as e:
99
- await client.send_message("KillerXSupport", f"Error banning user {event.from_user.id}: {e}")
100
- logger.error(f"Error banning user {event.from_user.id}: {e}")
101
-
102
- if new_status == ChatMemberStatus.MEMBER and event.new_chat_member.status == ChatMemberStatus.MEMBER:
103
- try:
104
- if await db.is_gbanned(user_id):
105
- text_ban = f"User {user_first_name} (ID: {user_id}) was banned from {event.chat.title} due to global ban."
106
- await client.ban_chat_member(
107
- event.chat.id,
108
- user_id,
109
- )
110
- await client.send_message("KillerXSupport", text_ban)
111
- logger.info(f"User {user_id} was globally banned and has been banned from the chat.")
112
- except Exception as e:
113
- await client.send_message("KillerXSupport", f"Error banning user {user_id}: {e}")
114
- logger.error(f"Error banning user {user_id}: {e}")