-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathhelpers.py
70 lines (62 loc) · 3.02 KB
/
helpers.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# (C) Arunkumar Shibu
# January 15th 2022
import asyncio
from info import DB_CHANNEL, FSUB_CHANNEL, CHANNEL_LINK, LIST
from pyrogram.errors import FloodWait, UserNotParticipant
from pyrogram.types import ChatPermissions, InlineKeyboardMarkup, InlineKeyboardButton
async def copy_msg(msg):
file = msg.document or msg.video
if file.file_name.split(".")[-1] in LIST:
return
else:
try:
await msg.copy(DB_CHANNEL)
except FloodWait as e:
await asyncio.sleep(e.x)
await msg.copy(DB_CHANNEL)
async def force_sub(bot, msg):
if msg.from_user is None:
return
try:
member = await bot.get_chat_member(FSUB_CHANNEL, msg.from_user.id)
if member.status == "banned":
await msg.reply(f"Sorry {msg.from_user.mention}!\n You are banned in our channel, you will be banned from here within 10 seconds")
await asyncio.sleep(10)
await bot.ban_chat_member(msg.chat.id, msg.from_user.id)
except UserNotParticipant:
await bot.restrict_chat_member(chat_id=msg.chat.id,
user_id=msg.from_user.id,
permissions=ChatPermissions(can_send_messages=False)
)
await msg.reply(f"Hello {msg.from_user.mention}!\n\nYou have to join in our channel to message here",
reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("🔥 Join Channel 🔥", url=CHANNEL_LINK)],
[InlineKeyboardButton("♻️ Try Again ♻️", callback_data=f"checksub_{msg.from_user.id}")]])
)
except Exception as e:
print(e)
async def auto_delete(Bot, msg):
chat, msg_id = msg.chat.id, msg.message_id
try:
await asyncio.sleep(600) # not tested, edit if you need
await Bot.delete_messages(chat, msg_id)
except Exception as e:
print(e)
async def check_fsub(bot, update):
user = int(update.data.split("_")[-1])
if update.from_user.id==user:
try:
member = await bot.get_chat_member(FSUB_CHANNEL, user)
except UserNotParticipant:
await update.answer("I like your smartness..\nBut don't be over smart 🤭", show_alert=True) # @subinps 😁
except Exception as e:
print(e)
else:
await bot.restrict_chat_member(chat_id=update.message.chat.id,
user_id=user,
permissions=ChatPermissions(can_send_messages=True,
can_send_media_messages=True,
can_send_other_messages=True)
)
await update.message.edit(f"Hello {update.from_user.mention}!\nWelcome to {update.message.chat.title}")
else:
await update.answer("That's not for you bruh 😂", show_alert=True)