Spaces:
Paused
Paused
Captain Ezio
commited on
Commit
·
adee216
1
Parent(s):
4112232
...
Browse files- Powers/plugins/auto_join.py +0 -147
Powers/plugins/auto_join.py
DELETED
|
@@ -1,147 +0,0 @@
|
|
| 1 |
-
from pyrogram import filters
|
| 2 |
-
from pyrogram.enums import ChatMemberStatus as CMS
|
| 3 |
-
from pyrogram.types import CallbackQuery, ChatJoinRequest
|
| 4 |
-
from pyrogram.types import InlineKeyboardButton as ikb
|
| 5 |
-
from pyrogram.types import InlineKeyboardMarkup as ikm
|
| 6 |
-
from pyrogram.types import Message
|
| 7 |
-
|
| 8 |
-
from Powers.bot_class import Gojo
|
| 9 |
-
from Powers.database.autojoin_db import AUTOJOIN
|
| 10 |
-
from Powers.supports import get_support_staff
|
| 11 |
-
from Powers.utils.custom_filters import admin_filter, command
|
| 12 |
-
|
| 13 |
-
SUPPORT_STAFF = get_support_staff()
|
| 14 |
-
|
| 15 |
-
@Gojo.on_message(command(["joinreq"]) & admin_filter)
|
| 16 |
-
async def accept_join_requests(c: Gojo, m: Message):
|
| 17 |
-
if m.chat.id == m.from_user.id:
|
| 18 |
-
await m.reply_text("Use it in groups")
|
| 19 |
-
return
|
| 20 |
-
|
| 21 |
-
split = m.command
|
| 22 |
-
a_j = AUTOJOIN()
|
| 23 |
-
|
| 24 |
-
if len(split) == 1:
|
| 25 |
-
txt = "**USAGE**\n/joinreq [on | off]"
|
| 26 |
-
await m.reply_text(txt)
|
| 27 |
-
return
|
| 28 |
-
else:
|
| 29 |
-
yes_no = split[1].lower()
|
| 30 |
-
if yes_no not in ["on","off"]:
|
| 31 |
-
txt = "**USAGE**\n/joinreq [on | off]"
|
| 32 |
-
await m.reply_text(txt)
|
| 33 |
-
return
|
| 34 |
-
|
| 35 |
-
else:
|
| 36 |
-
if yes_no == "on":
|
| 37 |
-
is_al = a_j.load_autojoin(m.chat.id)
|
| 38 |
-
|
| 39 |
-
if is_al:
|
| 40 |
-
txt = "Now I will approve all the join request of the chat\nIf you want that I will just notify admins about the join request use command\n//joinreqmode [manual | auto]"
|
| 41 |
-
await m.reply_text(txt)
|
| 42 |
-
return
|
| 43 |
-
else:
|
| 44 |
-
txt = "Auto approve join request is already on for this chat\nIf you want that I will just notify admins about the join request use command\n/joinreqmode [manual | auto]"
|
| 45 |
-
await m.reply_text(txt)
|
| 46 |
-
return
|
| 47 |
-
|
| 48 |
-
elif yes_no == "off":
|
| 49 |
-
a_j.remove_autojoin(m.chat.id)
|
| 50 |
-
txt = "Now I will neither auto approve join request nor notify any admins about it"
|
| 51 |
-
await m.reply_text(txt)
|
| 52 |
-
return
|
| 53 |
-
|
| 54 |
-
@Gojo.on_message(command("joinreqmode") & admin_filter)
|
| 55 |
-
async def join_request_mode(c: Gojo, m: Message):
|
| 56 |
-
if m.chat.id == m.from_user.id:
|
| 57 |
-
await m.reply_text("Use it in groups")
|
| 58 |
-
return
|
| 59 |
-
u_text = "**USAGE**\n/joinreqmode [auto | manual]\nauto: auto approve joins\nmanual: will notify admin about the join request"
|
| 60 |
-
|
| 61 |
-
split = m.command
|
| 62 |
-
a_j = AUTOJOIN()
|
| 63 |
-
|
| 64 |
-
if len(split) == 1:
|
| 65 |
-
await m.reply_text(u_text)
|
| 66 |
-
return
|
| 67 |
-
|
| 68 |
-
else:
|
| 69 |
-
auto_manual = split[1]
|
| 70 |
-
if auto_manual not in ["auto","manual"]:
|
| 71 |
-
await m.reply_text(u_text)
|
| 72 |
-
return
|
| 73 |
-
else:
|
| 74 |
-
a_j.update_join_type(m.chat.id,auto_manual)
|
| 75 |
-
txt = "Changed join request type"
|
| 76 |
-
await m.reply_text(txt)
|
| 77 |
-
return
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
@Gojo.on_chat_join_request(filters.group)
|
| 81 |
-
async def join_request_handler(c: Gojo, j: ChatJoinRequest):
|
| 82 |
-
chat = j.chat.id
|
| 83 |
-
aj = AUTOJOIN()
|
| 84 |
-
join_type = aj.get_autojoin(chat)
|
| 85 |
-
|
| 86 |
-
if not join_type:
|
| 87 |
-
return
|
| 88 |
-
|
| 89 |
-
user = j.from_user.id
|
| 90 |
-
userr = j.from_user
|
| 91 |
-
if join_type == "auto" or user in SUPPORT_STAFF:
|
| 92 |
-
await c.approve_chat_join_request(chat,user)
|
| 93 |
-
|
| 94 |
-
elif join_type == "manual":
|
| 95 |
-
txt = "New join request is available\n**USER's INFO**\n"
|
| 96 |
-
txt += f"Name: {userr.first_name} {userr.last_name if userr.last_name else ''}"
|
| 97 |
-
txt += f"Mention: {userr.mention}"
|
| 98 |
-
txt += f"Id: {user}"
|
| 99 |
-
txt += f"Scam: {'True' if userr.is_scam else 'False'}"
|
| 100 |
-
if userr.username:
|
| 101 |
-
txt+= f"Username: @{userr.username}"
|
| 102 |
-
kb = [
|
| 103 |
-
[
|
| 104 |
-
ikb("Accept",f"accept_joinreq_uest_{user}"),
|
| 105 |
-
ikb("Decline",f"decline_joinreq_uest_{user}")
|
| 106 |
-
]
|
| 107 |
-
]
|
| 108 |
-
await c.send_message(chat,txt,reply_markup=ikm(kb))
|
| 109 |
-
return
|
| 110 |
-
|
| 111 |
-
@Gojo.on_callback_query(filters.regex("^accept_joinreq_uest_") | filters.regex("^decline_joinreq_uest_"))
|
| 112 |
-
async def accept_decline_request(c:Gojo, q: CallbackQuery):
|
| 113 |
-
user_id = q.from_user.id
|
| 114 |
-
user_status = (await q.message.chat.get_member(user_id)).status
|
| 115 |
-
if user_status not in {CMS.OWNER, CMS.ADMINISTRATOR}:
|
| 116 |
-
await q.answer(
|
| 117 |
-
"You're not even an admin, don't try this explosive shit!",
|
| 118 |
-
show_alert=True,
|
| 119 |
-
)
|
| 120 |
-
return
|
| 121 |
-
|
| 122 |
-
split = q.data.split("_")
|
| 123 |
-
chat = q.message.chat.id
|
| 124 |
-
user = int(split[-1])
|
| 125 |
-
data = split[0]
|
| 126 |
-
|
| 127 |
-
if data == "accept":
|
| 128 |
-
await c.approve_chat_join_request(chat,user)
|
| 129 |
-
await q.answer(f"APPROVED: {user}",True)
|
| 130 |
-
elif data == "decline":
|
| 131 |
-
await c.decline_chat_join_request(chat,user)
|
| 132 |
-
await q.answer(f"DECLINED: {user}")
|
| 133 |
-
|
| 134 |
-
return
|
| 135 |
-
|
| 136 |
-
__PLUGIN__ = "auto join"
|
| 137 |
-
|
| 138 |
-
__alt_name__ = ["join_request"]
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
__HELP__ = """
|
| 142 |
-
**Auto join request**
|
| 143 |
-
|
| 144 |
-
**Admin commands:**
|
| 145 |
-
• /joinreq [on | off]: To switch on auto accept join request
|
| 146 |
-
• /joinreqmode [auto | manual]: `auto` to accept join request automatically and `manual` to get notified when new join request is available
|
| 147 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|