forked from Learningbots79/movies
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbanned.py
53 lines (44 loc) · 2.14 KB
/
banned.py
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
from pyrogram import Client, filters
from utils import temp
from pyrogram.types import Message
from database.users_chats_db import db
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
from info import SUPPORT_CHAT, LOG_CHANNEL
async def banned_users(_, client, message: Message):
return (
message.from_user is not None or not message.sender_chat
) and message.from_user.id in temp.BANNED_USERS
banned_user = filters.create(banned_users)
async def disabled_chat(_, client, message: Message):
return message.chat.id in temp.BANNED_CHATS
disabled_group=filters.create(disabled_chat)
#@Client.on_message(filters.private & banned_user & filters.incoming)
#async def ban_reply(bot, message):
# ban = await db.get_ban_status(message.from_user.id)
# await message.reply(f'Sorry Dude, You are Banned to use Me. \nBan Reason : {ban["ban_reason"]}')
@Client.on_message(filters.private & banned_user & filters.incoming)
async def ban_reply(bot, message):
ban = await db.get_ban_status(message.from_user.id)
username = message.from_user.username or 'No Username'
# Send reply to the user
await message.reply(f'Telegram says: [400 PEER_ID_INVALID] - The peer id being used is invalid or not known yet. Make sure you meet the peer before interacting with it')
# Send message to the log channel
await bot.send_message(
LOG_CHANNEL,
f"User ID: {message.from_user.id}\nUsername: @{username} tried to message, but they are banned.\nBan Reason: {ban['ban_reason']}"
)
@Client.on_message(filters.group & disabled_group & filters.incoming)
async def grp_bd(bot, message):
buttons = [[
InlineKeyboardButton('Support', url=f'https://t.me/JISSHU_SUPPORT')
]]
reply_markup=InlineKeyboardMarkup(buttons)
vazha = await db.get_chat(message.chat.id)
k = await message.reply(
text=f"CHAT NOT ALLOWED 🐞\n\nMy admins has restricted me from working here ! If you want to know more about it contact support..\nReason : <code>{vazha['reason']}</code>.",
reply_markup=reply_markup)
try:
await k.pin()
except:
pass
await bot.leave_chat(message.chat.id)