Spaces:
Paused
Paused
Captain Ezio
commited on
Commit
·
a3f3b83
1
Parent(s):
3588d38
Test completed
Browse files- Powers/database/captcha_db.py +10 -2
- Powers/plugins/auto_join.py +22 -11
- Powers/plugins/captcha.py +88 -48
- Powers/plugins/flood.py +21 -9
- Powers/plugins/greetings.py +103 -118
- Powers/plugins/locks.py +1 -2
- Powers/plugins/scheduled_jobs.py +5 -7
- Powers/plugins/start.py +26 -10
- Powers/plugins/stickers.py +1 -2
- Powers/utils/captcha_helper.py +5 -8
- Powers/utils/custom_filters.py +29 -4
- Powers/utils/sticker_help.py +2 -2
- requirements.txt +1 -1
Powers/database/captcha_db.py
CHANGED
|
@@ -101,11 +101,18 @@ class CAPTCHA_DATA(MongoDB):
|
|
| 101 |
return
|
| 102 |
else:
|
| 103 |
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
def is_already_data(self, chat, user):
|
| 106 |
curr = self.find_one({"chat_id": chat, "user_id": user})
|
| 107 |
if curr:
|
| 108 |
-
return curr
|
| 109 |
else:
|
| 110 |
return False
|
| 111 |
|
|
@@ -114,4 +121,5 @@ class CAPTCHA_DATA(MongoDB):
|
|
| 114 |
if curr:
|
| 115 |
with INSERTION_LOCK:
|
| 116 |
self.delete_one({"chat_id": chat, "user_id": user})
|
| 117 |
-
|
|
|
|
|
|
| 101 |
return
|
| 102 |
else:
|
| 103 |
return
|
| 104 |
+
|
| 105 |
+
def get_message_id(self, chat, user):
|
| 106 |
+
curr = self.find_one({"chat_id": chat, "user_id": user})
|
| 107 |
+
if curr:
|
| 108 |
+
return curr["message_id"]
|
| 109 |
+
else:
|
| 110 |
+
return False
|
| 111 |
|
| 112 |
def is_already_data(self, chat, user):
|
| 113 |
curr = self.find_one({"chat_id": chat, "user_id": user})
|
| 114 |
if curr:
|
| 115 |
+
return curr.get("message_id", False)
|
| 116 |
else:
|
| 117 |
return False
|
| 118 |
|
|
|
|
| 121 |
if curr:
|
| 122 |
with INSERTION_LOCK:
|
| 123 |
self.delete_one({"chat_id": chat, "user_id": user})
|
| 124 |
+
|
| 125 |
+
return curr["message_id"]
|
Powers/plugins/auto_join.py
CHANGED
|
@@ -48,7 +48,7 @@ async def accept_join_requests(c: Gojo, m: Message):
|
|
| 48 |
is_al = a_j.load_autojoin(m.chat.id)
|
| 49 |
|
| 50 |
if is_al:
|
| 51 |
-
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
|
| 52 |
await m.reply_text(txt)
|
| 53 |
return
|
| 54 |
else:
|
|
@@ -102,13 +102,16 @@ async def join_request_handler(c: Gojo, j: ChatJoinRequest):
|
|
| 102 |
if join_type == "auto" or user in SUPPORT_STAFF:
|
| 103 |
try:
|
| 104 |
await c.approve_chat_join_request(chat,user)
|
|
|
|
|
|
|
| 105 |
except Exception as ef:
|
| 106 |
await c.send_message(chat,f"Some error occured while approving request, report it using `/bug`\n<b>Error:</b> <code>{ef}</code>")
|
| 107 |
LOGGER.error(ef)
|
| 108 |
LOGGER.error(format_exc())
|
|
|
|
| 109 |
elif join_type == "manual":
|
| 110 |
txt = "New join request is available\n**USER's INFO**\n"
|
| 111 |
-
txt += f"Name: {userr.
|
| 112 |
txt += f"Mention: {userr.mention}"
|
| 113 |
txt += f"Id: {user}"
|
| 114 |
txt += f"Scam: {'True' if userr.is_scam else 'False'}"
|
|
@@ -127,23 +130,30 @@ async def join_request_handler(c: Gojo, j: ChatJoinRequest):
|
|
| 127 |
async def accept_decline_request(c:Gojo, q: CallbackQuery):
|
| 128 |
user_id = q.from_user.id
|
| 129 |
chat = q.message.chat.id
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
return
|
| 137 |
-
|
| 138 |
split = q.data.split("_")
|
| 139 |
chat = q.message.chat.id
|
| 140 |
user = int(split[-1])
|
| 141 |
data = split[0]
|
| 142 |
-
|
|
|
|
|
|
|
|
|
|
| 143 |
if data == "accept":
|
| 144 |
try:
|
| 145 |
await c.approve_chat_join_request(chat,user)
|
| 146 |
-
await q.answer(f"
|
|
|
|
| 147 |
except Exception as ef:
|
| 148 |
await c.send_message(chat,f"Some error occured while approving request, report it using `/bug`\n<b>Error:</b> <code>{ef}</code>")
|
| 149 |
LOGGER.error(ef)
|
|
@@ -153,6 +163,7 @@ async def accept_decline_request(c:Gojo, q: CallbackQuery):
|
|
| 153 |
try:
|
| 154 |
await c.decline_chat_join_request(chat,user)
|
| 155 |
await q.answer(f"DECLINED: {user}")
|
|
|
|
| 156 |
except Exception as ef:
|
| 157 |
await c.send_message(chat,f"Some error occured while approving request, report it using `/bug`\n<b>Error:</b> <code>{ef}</code>")
|
| 158 |
LOGGER.error(ef)
|
|
|
|
| 48 |
is_al = a_j.load_autojoin(m.chat.id)
|
| 49 |
|
| 50 |
if is_al:
|
| 51 |
+
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]"
|
| 52 |
await m.reply_text(txt)
|
| 53 |
return
|
| 54 |
else:
|
|
|
|
| 102 |
if join_type == "auto" or user in SUPPORT_STAFF:
|
| 103 |
try:
|
| 104 |
await c.approve_chat_join_request(chat,user)
|
| 105 |
+
await c.send_message(chat, f"Accepted join request of the {userr.mention}")
|
| 106 |
+
return
|
| 107 |
except Exception as ef:
|
| 108 |
await c.send_message(chat,f"Some error occured while approving request, report it using `/bug`\n<b>Error:</b> <code>{ef}</code>")
|
| 109 |
LOGGER.error(ef)
|
| 110 |
LOGGER.error(format_exc())
|
| 111 |
+
return
|
| 112 |
elif join_type == "manual":
|
| 113 |
txt = "New join request is available\n**USER's INFO**\n"
|
| 114 |
+
txt += f"Name: {userr.full_name}"
|
| 115 |
txt += f"Mention: {userr.mention}"
|
| 116 |
txt += f"Id: {user}"
|
| 117 |
txt += f"Scam: {'True' if userr.is_scam else 'False'}"
|
|
|
|
| 130 |
async def accept_decline_request(c:Gojo, q: CallbackQuery):
|
| 131 |
user_id = q.from_user.id
|
| 132 |
chat = q.message.chat.id
|
| 133 |
+
try:
|
| 134 |
+
user_status = (await q.message.chat.get_member(user_id)).status
|
| 135 |
+
if user_status not in {CMS.OWNER, CMS.ADMINISTRATOR}:
|
| 136 |
+
await q.answer(
|
| 137 |
+
"You're not even an admin, don't try this explosive shit!",
|
| 138 |
+
show_alert=True,
|
| 139 |
+
)
|
| 140 |
+
return
|
| 141 |
+
except:
|
| 142 |
+
await q.answer("Unknow error occured. You are not admin or owner")
|
| 143 |
return
|
|
|
|
| 144 |
split = q.data.split("_")
|
| 145 |
chat = q.message.chat.id
|
| 146 |
user = int(split[-1])
|
| 147 |
data = split[0]
|
| 148 |
+
try:
|
| 149 |
+
userr = await c.get_users(user)
|
| 150 |
+
except:
|
| 151 |
+
userr = None
|
| 152 |
if data == "accept":
|
| 153 |
try:
|
| 154 |
await c.approve_chat_join_request(chat,user)
|
| 155 |
+
await q.answer(f"Accepted join request of the {userr.mention if userr else user}",True)
|
| 156 |
+
await q.edit_message_text(f"Accepted join request of the {userr.mention if userr else user}")
|
| 157 |
except Exception as ef:
|
| 158 |
await c.send_message(chat,f"Some error occured while approving request, report it using `/bug`\n<b>Error:</b> <code>{ef}</code>")
|
| 159 |
LOGGER.error(ef)
|
|
|
|
| 163 |
try:
|
| 164 |
await c.decline_chat_join_request(chat,user)
|
| 165 |
await q.answer(f"DECLINED: {user}")
|
| 166 |
+
await q.edit_message_text()
|
| 167 |
except Exception as ef:
|
| 168 |
await c.send_message(chat,f"Some error occured while approving request, report it using `/bug`\n<b>Error:</b> <code>{ef}</code>")
|
| 169 |
LOGGER.error(ef)
|
Powers/plugins/captcha.py
CHANGED
|
@@ -1,23 +1,28 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
from traceback import format_exc
|
|
|
|
| 3 |
|
| 4 |
import pyrogram
|
| 5 |
from pyrogram import filters
|
| 6 |
-
from pyrogram.
|
|
|
|
|
|
|
| 7 |
from pyrogram.types import InlineKeyboardButton as IKB
|
| 8 |
from pyrogram.types import InlineKeyboardMarkup as ikm
|
| 9 |
-
from pyrogram.types import Message
|
| 10 |
|
| 11 |
-
from Powers import DEV_USERS, LOGGER, SUDO_USERS, WHITELIST_USERS
|
| 12 |
from Powers.bot_class import Gojo
|
| 13 |
from Powers.database.captcha_db import CAPTCHA, CAPTCHA_DATA
|
| 14 |
from Powers.utils.captcha_helper import (genrator, get_image_captcha,
|
| 15 |
get_qr_captcha)
|
| 16 |
-
from Powers.utils.custom_filters import admin_filter, command
|
|
|
|
| 17 |
|
| 18 |
|
| 19 |
@Gojo.on_message(command("captcha") & admin_filter & ~filters.private)
|
| 20 |
-
async def start_captcha(
|
| 21 |
captcha = CAPTCHA()
|
| 22 |
split = m.command
|
| 23 |
if len(split) == 1:
|
|
@@ -59,8 +64,9 @@ async def set_captcha_mode(c: Gojo, m: Message):
|
|
| 59 |
else:
|
| 60 |
type_ = split[1].lower()
|
| 61 |
if type_ == "qr":
|
| 62 |
-
|
| 63 |
-
|
|
|
|
| 64 |
return
|
| 65 |
elif type_ == "image":
|
| 66 |
captcha.update_type(m.chat.id, "image")
|
|
@@ -106,44 +112,73 @@ async def captcha_codes_check(c: Gojo, q: CallbackQuery):
|
|
| 106 |
new_cap = ":".join(caps)
|
| 107 |
await q.answer(f"Wrong\nTries left: {tries}", True)
|
| 108 |
if not tries:
|
| 109 |
-
|
| 110 |
try:
|
| 111 |
await q.message.chat.ban_member(user)
|
| 112 |
except Exception as e:
|
| 113 |
-
await q.message.reply_text("Failed to
|
| 114 |
return
|
| 115 |
await q.message.delete()
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
else:
|
| 120 |
await q.edit_message_caption(new_cap, reply_markup=q.message.reply_markup)
|
| 121 |
return
|
| 122 |
|
| 123 |
|
| 124 |
-
@Gojo.
|
| 125 |
-
async def on_chat_members_updatess(c: Gojo,
|
| 126 |
-
chat =
|
| 127 |
-
|
| 128 |
-
if u.new_chat_member:
|
| 129 |
-
|
| 130 |
-
user = u.new_chat_member.user.id
|
| 131 |
-
userr = u.new_chat_member.user
|
| 132 |
-
|
| 133 |
-
is_qr = CAPTCHA().is_captcha(chat)
|
| 134 |
-
if not is_qr:
|
| 135 |
-
return
|
| 136 |
|
|
|
|
|
|
|
| 137 |
captcha = CAPTCHA()
|
| 138 |
cap_data = CAPTCHA_DATA()
|
| 139 |
-
|
|
|
|
|
|
|
| 140 |
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
| 141 |
-
if user in SUPPORT_STAFF:
|
| 142 |
-
return
|
| 143 |
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
|
| 148 |
mess = False
|
| 149 |
try:
|
|
@@ -154,36 +189,40 @@ async def on_chat_members_updatess(c: Gojo, u: ChatMemberUpdated):
|
|
| 154 |
mess = False
|
| 155 |
is_already = False
|
| 156 |
|
| 157 |
-
if is_already and
|
| 158 |
cap_data.del_message_id(chat, is_already)
|
| 159 |
-
|
| 160 |
|
| 161 |
try:
|
| 162 |
-
await c.restrict_chat_member(chat, user, ChatPermissions())
|
| 163 |
except Exception as e:
|
| 164 |
LOGGER.error(e)
|
| 165 |
LOGGER.error(format_exc())
|
| 166 |
-
|
| 167 |
|
| 168 |
if not is_already:
|
|
|
|
| 169 |
if captcha_type == "qr":
|
| 170 |
-
pic = await get_qr_captcha(chat, user)
|
| 171 |
-
cap = f"Please {
|
| 172 |
ms = await c.send_photo(chat, pic, caption=cap)
|
| 173 |
-
|
| 174 |
-
|
|
|
|
| 175 |
elif captcha_type == "image":
|
| 176 |
-
img, code = await get_image_captcha(chat, user)
|
| 177 |
-
cap = f"Please {
|
| 178 |
-
cap_data.load_cap_data(chat, user, code)
|
| 179 |
rand = [code]
|
| 180 |
while len(rand) != 5:
|
| 181 |
hehe = genrator()
|
|
|
|
|
|
|
| 182 |
rand.append(hehe)
|
| 183 |
|
| 184 |
shuffle(rand)
|
| 185 |
|
| 186 |
-
ini = f"captcha_{chat}_{user}_"
|
| 187 |
|
| 188 |
kb = ikm(
|
| 189 |
[
|
|
@@ -205,7 +244,8 @@ async def on_chat_members_updatess(c: Gojo, u: ChatMemberUpdated):
|
|
| 205 |
]
|
| 206 |
)
|
| 207 |
await c.send_photo(chat, img, caption=cap, reply_markup=kb)
|
| 208 |
-
|
|
|
|
| 209 |
elif is_already and mess:
|
| 210 |
kb = ikm(
|
| 211 |
[
|
|
@@ -214,11 +254,11 @@ async def on_chat_members_updatess(c: Gojo, u: ChatMemberUpdated):
|
|
| 214 |
]
|
| 215 |
]
|
| 216 |
)
|
| 217 |
-
await c.send_message(f"{
|
| 218 |
-
|
| 219 |
else:
|
| 220 |
-
await c.unban_chat_member(chat, user)
|
| 221 |
-
|
| 222 |
|
| 223 |
|
| 224 |
__PLUGIN__ = "captcha"
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from random import choice, shuffle
|
| 3 |
from traceback import format_exc
|
| 4 |
+
from typing import List
|
| 5 |
|
| 6 |
import pyrogram
|
| 7 |
from pyrogram import filters
|
| 8 |
+
from pyrogram.enums import ChatMemberStatus as CMS
|
| 9 |
+
from pyrogram.enums import ParseMode as PM
|
| 10 |
+
from pyrogram.types import CallbackQuery, ChatPermissions
|
| 11 |
from pyrogram.types import InlineKeyboardButton as IKB
|
| 12 |
from pyrogram.types import InlineKeyboardMarkup as ikm
|
| 13 |
+
from pyrogram.types import Message, User
|
| 14 |
|
| 15 |
+
from Powers import DEV_USERS, LOGGER, MESSAGE_DUMP, SUDO_USERS, WHITELIST_USERS
|
| 16 |
from Powers.bot_class import Gojo
|
| 17 |
from Powers.database.captcha_db import CAPTCHA, CAPTCHA_DATA
|
| 18 |
from Powers.utils.captcha_helper import (genrator, get_image_captcha,
|
| 19 |
get_qr_captcha)
|
| 20 |
+
from Powers.utils.custom_filters import admin_filter, captcha_filter, command
|
| 21 |
+
from Powers.utils.extras import BAN_GIFS
|
| 22 |
|
| 23 |
|
| 24 |
@Gojo.on_message(command("captcha") & admin_filter & ~filters.private)
|
| 25 |
+
async def start_captcha(_, m: Message):
|
| 26 |
captcha = CAPTCHA()
|
| 27 |
split = m.command
|
| 28 |
if len(split) == 1:
|
|
|
|
| 64 |
else:
|
| 65 |
type_ = split[1].lower()
|
| 66 |
if type_ == "qr":
|
| 67 |
+
await m.reply_text("This feature is not implemented yet\nUse /captchamode image")
|
| 68 |
+
# captcha.update_type(m.chat.id, "qr")
|
| 69 |
+
# await m.reply_text("Captcha verification is now changed to qr code")
|
| 70 |
return
|
| 71 |
elif type_ == "image":
|
| 72 |
captcha.update_type(m.chat.id, "image")
|
|
|
|
| 112 |
new_cap = ":".join(caps)
|
| 113 |
await q.answer(f"Wrong\nTries left: {tries}", True)
|
| 114 |
if not tries:
|
| 115 |
+
txt = f"{q.from_user.mention} was not able to pass captcha verification thus banned from the group"
|
| 116 |
try:
|
| 117 |
await q.message.chat.ban_member(user)
|
| 118 |
except Exception as e:
|
| 119 |
+
await q.message.reply_text("Failed to ban member")
|
| 120 |
return
|
| 121 |
await q.message.delete()
|
| 122 |
+
keyboard = ikm(
|
| 123 |
+
[
|
| 124 |
+
[
|
| 125 |
+
IKB(
|
| 126 |
+
"Unban",
|
| 127 |
+
callback_data=f"unban_={user}",
|
| 128 |
+
),
|
| 129 |
+
],
|
| 130 |
+
],
|
| 131 |
+
)
|
| 132 |
+
anim = choice(BAN_GIFS)
|
| 133 |
+
try:
|
| 134 |
+
await c.send_animation(
|
| 135 |
+
chat_id=q.message.chat.id,
|
| 136 |
+
animation=str(anim),
|
| 137 |
+
caption=txt,
|
| 138 |
+
reply_markup=keyboard,
|
| 139 |
+
parse_mode=PM.HTML,
|
| 140 |
+
)
|
| 141 |
+
except Exception:
|
| 142 |
+
|
| 143 |
+
await c.send_animation(
|
| 144 |
+
chat_id=q.message.chat.id,
|
| 145 |
+
text=txt,
|
| 146 |
+
reply_markup=keyboard,
|
| 147 |
+
parse_mode=PM.HTML,
|
| 148 |
+
)
|
| 149 |
+
await c.send_message(MESSAGE_DUMP,f"#REMOVE from BAN_GFIS\n{anim}")
|
| 150 |
+
c_data.remove_cap_data(chat, user)
|
| 151 |
+
c_data.del_message_id(q.message.chat.id, user)
|
| 152 |
+
return
|
| 153 |
else:
|
| 154 |
await q.edit_message_caption(new_cap, reply_markup=q.message.reply_markup)
|
| 155 |
return
|
| 156 |
|
| 157 |
|
| 158 |
+
@Gojo.on_message(filters.group & captcha_filter & filters.new_chat_members, group=3)
|
| 159 |
+
async def on_chat_members_updatess(c: Gojo, m: Message):
|
| 160 |
+
chat = m.chat.id
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
|
| 162 |
+
users: List[User] = m.new_chat_members
|
| 163 |
+
for user in users:
|
| 164 |
captcha = CAPTCHA()
|
| 165 |
cap_data = CAPTCHA_DATA()
|
| 166 |
+
|
| 167 |
+
if user.is_bot:
|
| 168 |
+
continue
|
| 169 |
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
|
|
|
|
|
|
| 170 |
|
| 171 |
+
try:
|
| 172 |
+
status = (await m.chat.get_member(user)).status
|
| 173 |
+
if status in [CMS.OWNER, CMS.ADMINISTRATOR]:
|
| 174 |
+
continue
|
| 175 |
+
except:
|
| 176 |
+
pass
|
| 177 |
+
if user.id in SUPPORT_STAFF:
|
| 178 |
+
continue
|
| 179 |
+
captcha_info = captcha.get_captcha(chat)
|
| 180 |
+
captcha_type = captcha_info["captcha_type"]
|
| 181 |
+
is_already = cap_data.is_already_data(chat, user.id)
|
| 182 |
|
| 183 |
mess = False
|
| 184 |
try:
|
|
|
|
| 189 |
mess = False
|
| 190 |
is_already = False
|
| 191 |
|
| 192 |
+
if is_already and mess.empty:
|
| 193 |
cap_data.del_message_id(chat, is_already)
|
| 194 |
+
continue
|
| 195 |
|
| 196 |
try:
|
| 197 |
+
await c.restrict_chat_member(chat, user.id, ChatPermissions())
|
| 198 |
except Exception as e:
|
| 199 |
LOGGER.error(e)
|
| 200 |
LOGGER.error(format_exc())
|
| 201 |
+
continue
|
| 202 |
|
| 203 |
if not is_already:
|
| 204 |
+
captcha_type = "image" # I am not going to apply qr captcha in this update
|
| 205 |
if captcha_type == "qr":
|
| 206 |
+
pic = await get_qr_captcha(chat, user.id, c.me.username)
|
| 207 |
+
cap = f"Please {user.mention} scan this qr code with your phone to verify that you are human"
|
| 208 |
ms = await c.send_photo(chat, pic, caption=cap)
|
| 209 |
+
os.remove(pic)
|
| 210 |
+
cap_data.store_message_id(chat, user.id, ms.id)
|
| 211 |
+
continue
|
| 212 |
elif captcha_type == "image":
|
| 213 |
+
img, code = await get_image_captcha(chat, user.id)
|
| 214 |
+
cap = f"Please {user.mention} please choose the correct code from the one given bellow\nYou have three tries if you get all three wrong u will be banned from the chat.\nTries left: 3"
|
| 215 |
+
cap_data.load_cap_data(chat, user.id, code)
|
| 216 |
rand = [code]
|
| 217 |
while len(rand) != 5:
|
| 218 |
hehe = genrator()
|
| 219 |
+
if hehe == code:
|
| 220 |
+
continue
|
| 221 |
rand.append(hehe)
|
| 222 |
|
| 223 |
shuffle(rand)
|
| 224 |
|
| 225 |
+
ini = f"captcha_{chat}_{user.id}_"
|
| 226 |
|
| 227 |
kb = ikm(
|
| 228 |
[
|
|
|
|
| 244 |
]
|
| 245 |
)
|
| 246 |
await c.send_photo(chat, img, caption=cap, reply_markup=kb)
|
| 247 |
+
os.remove(img)
|
| 248 |
+
continue
|
| 249 |
elif is_already and mess:
|
| 250 |
kb = ikm(
|
| 251 |
[
|
|
|
|
| 254 |
]
|
| 255 |
]
|
| 256 |
)
|
| 257 |
+
await c.send_message(f"{user.mention} your verification is already pending", reply_markup=kb)
|
| 258 |
+
continue
|
| 259 |
else:
|
| 260 |
+
await c.unban_chat_member(chat, user.id)
|
| 261 |
+
continue
|
| 262 |
|
| 263 |
|
| 264 |
__PLUGIN__ = "captcha"
|
Powers/plugins/flood.py
CHANGED
|
@@ -212,12 +212,17 @@ async def flood_set(c: Gojo, m: Message):
|
|
| 212 |
c_id = m.chat.id
|
| 213 |
if split[1].lower() in on_key:
|
| 214 |
if is_flood:
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
|
|
|
|
|
|
| 218 |
return
|
| 219 |
if split[1].lower() in off_key:
|
| 220 |
x = Flood.rm_flood(c_id)
|
|
|
|
|
|
|
|
|
|
| 221 |
if x:
|
| 222 |
await m.reply_text("Flood protection has been stopped for this chat")
|
| 223 |
return
|
|
@@ -322,8 +327,8 @@ async def callbacks(c: Gojo, q: CallbackQuery):
|
|
| 322 |
"Flood protection setting has been updated",
|
| 323 |
reply_markup=close_kb
|
| 324 |
)
|
| 325 |
-
return
|
| 326 |
await q.answer("skip")
|
|
|
|
| 327 |
if not change == swithin:
|
| 328 |
Flood.save_flood(c_id, slimit, change, saction)
|
| 329 |
await q.answer("Updated", show_alert=True)
|
|
@@ -390,7 +395,7 @@ async def reverse_callbacks(c: Gojo, q: CallbackQuery):
|
|
| 390 |
return
|
| 391 |
|
| 392 |
dic = {}
|
| 393 |
-
@Gojo.on_message(flood_filter
|
| 394 |
async def flood_watcher(c: Gojo, m: Message):
|
| 395 |
c_id = m.chat.id
|
| 396 |
|
|
@@ -573,13 +578,14 @@ async def flood_watcher(c: Gojo, m: Message):
|
|
| 573 |
|
| 574 |
elif action == "kick":
|
| 575 |
try:
|
| 576 |
-
|
| 577 |
-
|
|
|
|
|
|
|
| 578 |
await m.reply_animation(
|
| 579 |
animation=str(choice(KICK_GIFS)),
|
| 580 |
-
caption=txt
|
| 581 |
)
|
| 582 |
-
await m.chat.unban_member(m.from_user.id)
|
| 583 |
dic[c_id][u_id][1].clear()
|
| 584 |
dic[c_id][u_id][0].clear()
|
| 585 |
return
|
|
@@ -601,6 +607,12 @@ async def flood_watcher(c: Gojo, m: Message):
|
|
| 601 |
dic[c_id][u_id][1].clear()
|
| 602 |
dic[c_id][u_id][0].clear()
|
| 603 |
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 604 |
elif action == "mute":
|
| 605 |
try:
|
| 606 |
await m.chat.restrict_member(
|
|
|
|
| 212 |
c_id = m.chat.id
|
| 213 |
if split[1].lower() in on_key:
|
| 214 |
if is_flood:
|
| 215 |
+
saction = is_flood[2]
|
| 216 |
+
slimit = is_flood[0]
|
| 217 |
+
swithin = is_flood[1]
|
| 218 |
+
|
| 219 |
+
await m.reply_text(f"Flood is on for this chat\n**Action**:{saction}\n**Messages**:{slimit} within {swithin} sec")
|
| 220 |
return
|
| 221 |
if split[1].lower() in off_key:
|
| 222 |
x = Flood.rm_flood(c_id)
|
| 223 |
+
if not is_flood:
|
| 224 |
+
await m.reply_text("Flood protection is already off for this chat")
|
| 225 |
+
return
|
| 226 |
if x:
|
| 227 |
await m.reply_text("Flood protection has been stopped for this chat")
|
| 228 |
return
|
|
|
|
| 327 |
"Flood protection setting has been updated",
|
| 328 |
reply_markup=close_kb
|
| 329 |
)
|
|
|
|
| 330 |
await q.answer("skip")
|
| 331 |
+
return
|
| 332 |
if not change == swithin:
|
| 333 |
Flood.save_flood(c_id, slimit, change, saction)
|
| 334 |
await q.answer("Updated", show_alert=True)
|
|
|
|
| 395 |
return
|
| 396 |
|
| 397 |
dic = {}
|
| 398 |
+
@Gojo.on_message(flood_filter, 18)
|
| 399 |
async def flood_watcher(c: Gojo, m: Message):
|
| 400 |
c_id = m.chat.id
|
| 401 |
|
|
|
|
| 578 |
|
| 579 |
elif action == "kick":
|
| 580 |
try:
|
| 581 |
+
d = datetime.now()+timedelta(seconds=31) #will automatically unban user after 31 seconds kind of fail safe if unban members doesn't work properly
|
| 582 |
+
await m.chat.ban_member(u_id, until_date=d)
|
| 583 |
+
success = await c.unban_chat_member(m.chat.id, u_id)
|
| 584 |
+
txt = f"Don't dare to spam here if I am around! Nothing can escape my 6 eyes\nAction: {'kicked' if success else 'banned for 30 seconds'}\nReason: Spaming"
|
| 585 |
await m.reply_animation(
|
| 586 |
animation=str(choice(KICK_GIFS)),
|
| 587 |
+
caption=txt
|
| 588 |
)
|
|
|
|
| 589 |
dic[c_id][u_id][1].clear()
|
| 590 |
dic[c_id][u_id][0].clear()
|
| 591 |
return
|
|
|
|
| 607 |
dic[c_id][u_id][1].clear()
|
| 608 |
dic[c_id][u_id][0].clear()
|
| 609 |
return
|
| 610 |
+
except Exception as e:
|
| 611 |
+
LOGGER.error(e)
|
| 612 |
+
LOGGER.error(format_exc())
|
| 613 |
+
dic[c_id][u_id][1].clear()
|
| 614 |
+
dic[c_id][u_id][0].clear()
|
| 615 |
+
return
|
| 616 |
elif action == "mute":
|
| 617 |
try:
|
| 618 |
await m.chat.restrict_member(
|
Powers/plugins/greetings.py
CHANGED
|
@@ -1,18 +1,19 @@
|
|
| 1 |
from html import escape
|
| 2 |
from secrets import choice
|
| 3 |
from traceback import format_exc
|
|
|
|
| 4 |
|
| 5 |
from pyrogram import emoji, enums, filters
|
| 6 |
-
from pyrogram.enums import ChatMemberStatus as CMS
|
| 7 |
from pyrogram.errors import ChannelPrivate, ChatAdminRequired, RPCError
|
| 8 |
-
from pyrogram.types import
|
| 9 |
|
| 10 |
from Powers import DEV_USERS, LOGGER
|
| 11 |
from Powers.bot_class import Gojo
|
| 12 |
from Powers.database.antispam_db import GBan
|
| 13 |
from Powers.database.greetings_db import Greetings
|
| 14 |
from Powers.utils.cmd_senders import send_cmd
|
| 15 |
-
from Powers.utils.custom_filters import admin_filter, bot_admin_filter,
|
|
|
|
| 16 |
from Powers.utils.kbhelpers import ikb
|
| 17 |
from Powers.utils.msg_types import Types, get_wlcm_type
|
| 18 |
from Powers.utils.parser import escape_markdown, mention_html
|
|
@@ -25,17 +26,13 @@ gdb = GBan()
|
|
| 25 |
ChatType = enums.ChatType
|
| 26 |
|
| 27 |
|
| 28 |
-
async def
|
| 29 |
-
|
| 30 |
-
|
| 31 |
text: str,
|
| 32 |
parse_words: list,
|
| 33 |
) -> str:
|
| 34 |
teks = await escape_invalid_curly_brackets(text, parse_words)
|
| 35 |
-
if n:
|
| 36 |
-
user = m.new_chat_member.user if m.new_chat_member else m.from_user
|
| 37 |
-
else:
|
| 38 |
-
user = m.old_chat_member.user if m.old_chat_member else m.from_user
|
| 39 |
if teks:
|
| 40 |
teks = teks.format(
|
| 41 |
first=escape(user.first_name),
|
|
@@ -235,113 +232,101 @@ async def cleannnnn(_, m: Message):
|
|
| 235 |
except Exception:
|
| 236 |
pass
|
| 237 |
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
else:
|
| 245 |
-
return
|
| 246 |
-
|
| 247 |
-
user = member.new_chat_member.user if member.new_chat_member else member.from_user
|
| 248 |
-
|
| 249 |
-
db = Greetings(member.chat.id)
|
| 250 |
-
banned_users = gdb.check_gban(user.id)
|
| 251 |
-
try:
|
| 252 |
-
if user.id == c.me.id:
|
| 253 |
-
return
|
| 254 |
-
if user.id in DEV_USERS:
|
| 255 |
-
await c.send_animation(
|
| 256 |
-
chat_id=member.chat.id,
|
| 257 |
-
animation="./extras/william.gif",
|
| 258 |
-
caption=f"😳 My **DEV** {user.mention} has also joined the chat!",
|
| 259 |
-
)
|
| 260 |
-
return
|
| 261 |
-
if banned_users:
|
| 262 |
-
await member.chat.ban_member(user.id)
|
| 263 |
-
await c.send_message(
|
| 264 |
-
member.chat.id,
|
| 265 |
-
f"{user.mention} was globally banned so i banned!",
|
| 266 |
-
)
|
| 267 |
-
return
|
| 268 |
-
if user.is_bot:
|
| 269 |
-
return # ignore bots
|
| 270 |
-
except ChatAdminRequired:
|
| 271 |
-
return
|
| 272 |
-
status = db.get_welcome_status()
|
| 273 |
-
oo = db.get_welcome_text()
|
| 274 |
-
UwU = db.get_welcome_media()
|
| 275 |
-
mtype = db.get_welcome_msgtype()
|
| 276 |
-
parse_words = [
|
| 277 |
-
"first",
|
| 278 |
-
"last",
|
| 279 |
-
"fullname",
|
| 280 |
-
"username",
|
| 281 |
-
"mention",
|
| 282 |
-
"id",
|
| 283 |
-
"chatname",
|
| 284 |
-
]
|
| 285 |
-
hmm = await escape_mentions_using_curly_brackets_wl(member, True, oo, parse_words)
|
| 286 |
-
if status:
|
| 287 |
-
tek, button = await parse_button(hmm)
|
| 288 |
-
button = await build_keyboard(button)
|
| 289 |
-
button = ikb(button) if button else None
|
| 290 |
-
|
| 291 |
-
if "%%%" in tek:
|
| 292 |
-
filter_reply = tek.split("%%%")
|
| 293 |
-
teks = choice(filter_reply)
|
| 294 |
-
else:
|
| 295 |
-
teks = tek
|
| 296 |
-
|
| 297 |
-
if not teks:
|
| 298 |
-
teks = f"A wild {user.mention} appeared in {member.chat.title}! Everyone be aware."
|
| 299 |
-
|
| 300 |
-
ifff = db.get_current_cleanwelcome_id()
|
| 301 |
-
gg = db.get_current_cleanwelcome_settings()
|
| 302 |
-
if ifff and gg:
|
| 303 |
-
try:
|
| 304 |
-
await c.delete_messages(member.chat.id, int(ifff))
|
| 305 |
-
except RPCError:
|
| 306 |
-
pass
|
| 307 |
-
if not teks:
|
| 308 |
-
teks = "Hey {first}, welcome to {chatname}"
|
| 309 |
try:
|
| 310 |
-
if
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
|
|
|
| 316 |
)
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 324 |
|
| 325 |
-
if jj:
|
| 326 |
-
db.set_cleanwlcm_id(int(jj.id))
|
| 327 |
-
except ChannelPrivate:
|
| 328 |
-
return
|
| 329 |
-
except RPCError as e:
|
| 330 |
-
LOGGER.error(e)
|
| 331 |
-
LOGGER.error(format_exc(e))
|
| 332 |
-
return
|
| 333 |
-
else:
|
| 334 |
-
return
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
@Gojo.on_chat_member_updated(filters.group, group=99)
|
| 338 |
-
async def member_has_left(c: Gojo, member: ChatMemberUpdated):
|
| 339 |
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
return
|
| 344 |
-
db = Greetings(member.chat.id)
|
| 345 |
status = db.get_goodbye_status()
|
| 346 |
oo = db.get_goodbye_text()
|
| 347 |
UwU = db.get_goodbye_media()
|
|
@@ -356,9 +341,9 @@ async def member_has_left(c: Gojo, member: ChatMemberUpdated):
|
|
| 356 |
"chatname",
|
| 357 |
]
|
| 358 |
|
| 359 |
-
user =
|
| 360 |
|
| 361 |
-
hmm = await escape_mentions_using_curly_brackets_wl(
|
| 362 |
if status:
|
| 363 |
tek, button = await parse_button(hmm)
|
| 364 |
button = await build_keyboard(button)
|
|
@@ -377,12 +362,12 @@ async def member_has_left(c: Gojo, member: ChatMemberUpdated):
|
|
| 377 |
iii = db.get_current_cleangoodbye_settings()
|
| 378 |
if ifff and iii:
|
| 379 |
try:
|
| 380 |
-
await c.delete_messages(
|
| 381 |
except RPCError:
|
| 382 |
pass
|
| 383 |
if user.id in DEV_USERS:
|
| 384 |
await c.send_message(
|
| 385 |
-
|
| 386 |
f"Will miss you my master {user.mention} :(",
|
| 387 |
)
|
| 388 |
return
|
|
@@ -391,14 +376,14 @@ async def member_has_left(c: Gojo, member: ChatMemberUpdated):
|
|
| 391 |
try:
|
| 392 |
if not UwU:
|
| 393 |
ooo = await c.send_message(
|
| 394 |
-
|
| 395 |
text=teks,
|
| 396 |
reply_markup=button,
|
| 397 |
disable_web_page_preview=True,
|
| 398 |
)
|
| 399 |
elif UwU:
|
| 400 |
ooo = await (await send_cmd(c,mtype))(
|
| 401 |
-
|
| 402 |
UwU,
|
| 403 |
caption=teks,
|
| 404 |
reply_markup=button,
|
|
|
|
| 1 |
from html import escape
|
| 2 |
from secrets import choice
|
| 3 |
from traceback import format_exc
|
| 4 |
+
from typing import List
|
| 5 |
|
| 6 |
from pyrogram import emoji, enums, filters
|
|
|
|
| 7 |
from pyrogram.errors import ChannelPrivate, ChatAdminRequired, RPCError
|
| 8 |
+
from pyrogram.types import Message, User
|
| 9 |
|
| 10 |
from Powers import DEV_USERS, LOGGER
|
| 11 |
from Powers.bot_class import Gojo
|
| 12 |
from Powers.database.antispam_db import GBan
|
| 13 |
from Powers.database.greetings_db import Greetings
|
| 14 |
from Powers.utils.cmd_senders import send_cmd
|
| 15 |
+
from Powers.utils.custom_filters import (admin_filter, bot_admin_filter,
|
| 16 |
+
captcha_filter, command)
|
| 17 |
from Powers.utils.kbhelpers import ikb
|
| 18 |
from Powers.utils.msg_types import Types, get_wlcm_type
|
| 19 |
from Powers.utils.parser import escape_markdown, mention_html
|
|
|
|
| 26 |
ChatType = enums.ChatType
|
| 27 |
|
| 28 |
|
| 29 |
+
async def escape_mentions_using_curly_brackets_wl(
|
| 30 |
+
user: User,
|
| 31 |
+
m: Message,
|
| 32 |
text: str,
|
| 33 |
parse_words: list,
|
| 34 |
) -> str:
|
| 35 |
teks = await escape_invalid_curly_brackets(text, parse_words)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
if teks:
|
| 37 |
teks = teks.format(
|
| 38 |
first=escape(user.first_name),
|
|
|
|
| 232 |
except Exception:
|
| 233 |
pass
|
| 234 |
|
| 235 |
+
@Gojo.on_message(filters.group & filters.new_chat_members & ~captcha_filter, group=69)
|
| 236 |
+
async def member_has_joined(c: Gojo, m: Message):
|
| 237 |
+
users: List[User] = m.new_chat_members
|
| 238 |
+
db = Greetings(m.chat.id)
|
| 239 |
+
for user in users:
|
| 240 |
+
banned_users = gdb.check_gban(user.id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
try:
|
| 242 |
+
if user.id == c.me.id:
|
| 243 |
+
continue
|
| 244 |
+
if user.id in DEV_USERS:
|
| 245 |
+
await c.send_animation(
|
| 246 |
+
chat_id=m.chat.id,
|
| 247 |
+
animation="./extras/william.gif",
|
| 248 |
+
caption=f"😳 My **DEV** {user.mention} has also joined the chat!",
|
| 249 |
)
|
| 250 |
+
continue
|
| 251 |
+
if banned_users:
|
| 252 |
+
await m.chat.ban_member(user.id)
|
| 253 |
+
await c.send_message(
|
| 254 |
+
m.chat.id,
|
| 255 |
+
f"{user.mention} was globally banned so i banned!",
|
| 256 |
)
|
| 257 |
+
continue
|
| 258 |
+
if user.is_bot:
|
| 259 |
+
continue # ignore bots
|
| 260 |
+
except ChatAdminRequired:
|
| 261 |
+
continue
|
| 262 |
+
status = db.get_welcome_status()
|
| 263 |
+
oo = db.get_welcome_text()
|
| 264 |
+
UwU = db.get_welcome_media()
|
| 265 |
+
mtype = db.get_welcome_msgtype()
|
| 266 |
+
parse_words = [
|
| 267 |
+
"first",
|
| 268 |
+
"last",
|
| 269 |
+
"fullname",
|
| 270 |
+
"username",
|
| 271 |
+
"mention",
|
| 272 |
+
"id",
|
| 273 |
+
"chatname",
|
| 274 |
+
]
|
| 275 |
+
hmm = await escape_mentions_using_curly_brackets_wl(user, m, oo, parse_words)
|
| 276 |
+
if status:
|
| 277 |
+
tek, button = await parse_button(hmm)
|
| 278 |
+
button = await build_keyboard(button)
|
| 279 |
+
button = ikb(button) if button else None
|
| 280 |
+
|
| 281 |
+
if "%%%" in tek:
|
| 282 |
+
filter_reply = tek.split("%%%")
|
| 283 |
+
teks = choice(filter_reply)
|
| 284 |
+
else:
|
| 285 |
+
teks = tek
|
| 286 |
+
|
| 287 |
+
if not teks:
|
| 288 |
+
teks = f"A wild {user.mention} appeared in {m.chat.title}! Everyone be aware."
|
| 289 |
+
|
| 290 |
+
ifff = db.get_current_cleanwelcome_id()
|
| 291 |
+
gg = db.get_current_cleanwelcome_settings()
|
| 292 |
+
if ifff and gg:
|
| 293 |
+
try:
|
| 294 |
+
await c.delete_messages(m.chat.id, int(ifff))
|
| 295 |
+
except RPCError:
|
| 296 |
+
pass
|
| 297 |
+
if not teks:
|
| 298 |
+
teks = "Hey {first}, welcome to {chatname}"
|
| 299 |
+
try:
|
| 300 |
+
if not UwU:
|
| 301 |
+
jj = await c.send_message(
|
| 302 |
+
m.chat.id,
|
| 303 |
+
text=teks,
|
| 304 |
+
reply_markup=button,
|
| 305 |
+
disable_web_page_preview=True,
|
| 306 |
+
)
|
| 307 |
+
elif UwU:
|
| 308 |
+
jj = await (await send_cmd(c,mtype))(
|
| 309 |
+
m.chat.id,
|
| 310 |
+
UwU,
|
| 311 |
+
caption=teks,
|
| 312 |
+
reply_markup=button,
|
| 313 |
+
)
|
| 314 |
+
|
| 315 |
+
if jj:
|
| 316 |
+
db.set_cleanwlcm_id(int(jj.id))
|
| 317 |
+
except ChannelPrivate:
|
| 318 |
+
continue
|
| 319 |
+
except RPCError as e:
|
| 320 |
+
LOGGER.error(e)
|
| 321 |
+
LOGGER.error(format_exc(e))
|
| 322 |
+
continue
|
| 323 |
+
else:
|
| 324 |
+
continue
|
| 325 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 326 |
|
| 327 |
+
@Gojo.on_message(filters.group & filters.left_chat_member, group=99)
|
| 328 |
+
async def member_has_left(c: Gojo, m: Message):
|
| 329 |
+
db = Greetings(m.chat.id)
|
|
|
|
|
|
|
| 330 |
status = db.get_goodbye_status()
|
| 331 |
oo = db.get_goodbye_text()
|
| 332 |
UwU = db.get_goodbye_media()
|
|
|
|
| 341 |
"chatname",
|
| 342 |
]
|
| 343 |
|
| 344 |
+
user = m.left_chat_member if m.left_chat_member else m.from_user
|
| 345 |
|
| 346 |
+
hmm = await escape_mentions_using_curly_brackets_wl(user, m, oo, parse_words)
|
| 347 |
if status:
|
| 348 |
tek, button = await parse_button(hmm)
|
| 349 |
button = await build_keyboard(button)
|
|
|
|
| 362 |
iii = db.get_current_cleangoodbye_settings()
|
| 363 |
if ifff and iii:
|
| 364 |
try:
|
| 365 |
+
await c.delete_messages(m.chat.id, int(ifff))
|
| 366 |
except RPCError:
|
| 367 |
pass
|
| 368 |
if user.id in DEV_USERS:
|
| 369 |
await c.send_message(
|
| 370 |
+
m.chat.id,
|
| 371 |
f"Will miss you my master {user.mention} :(",
|
| 372 |
)
|
| 373 |
return
|
|
|
|
| 376 |
try:
|
| 377 |
if not UwU:
|
| 378 |
ooo = await c.send_message(
|
| 379 |
+
m.chat.id,
|
| 380 |
text=teks,
|
| 381 |
reply_markup=button,
|
| 382 |
disable_web_page_preview=True,
|
| 383 |
)
|
| 384 |
elif UwU:
|
| 385 |
ooo = await (await send_cmd(c,mtype))(
|
| 386 |
+
m.chat.id,
|
| 387 |
UwU,
|
| 388 |
caption=teks,
|
| 389 |
reply_markup=button,
|
Powers/plugins/locks.py
CHANGED
|
@@ -464,10 +464,9 @@ async def is_approved_user(c: Gojo, m: Message):
|
|
| 464 |
return True
|
| 465 |
return False
|
| 466 |
elif m.forward_from_chat:
|
| 467 |
-
x_chat = (await c.get_chat(m.forward_from_chat.id)).linked_chat
|
| 468 |
if m.from_user and (m.from_user.id in ul or m.from_user.id in SUDO_LEVEL or m.from_user.id in admins_group or m.from_user.id == c.me.id):
|
| 469 |
return True
|
| 470 |
-
elif
|
| 471 |
return True
|
| 472 |
else:
|
| 473 |
return False
|
|
|
|
| 464 |
return True
|
| 465 |
return False
|
| 466 |
elif m.forward_from_chat:
|
|
|
|
| 467 |
if m.from_user and (m.from_user.id in ul or m.from_user.id in SUDO_LEVEL or m.from_user.id in admins_group or m.from_user.id == c.me.id):
|
| 468 |
return True
|
| 469 |
+
elif m.automatic_forward:
|
| 470 |
return True
|
| 471 |
else:
|
| 472 |
return False
|
Powers/plugins/scheduled_jobs.py
CHANGED
|
@@ -38,14 +38,12 @@ async def send_wishish(JJK: Client):
|
|
| 38 |
agee = ""
|
| 39 |
if i["is_year"]:
|
| 40 |
agee = curr.year - dob.year
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
agee = f"{agee}nd"
|
| 45 |
-
elif str(agee).endswith("3"):
|
| 46 |
-
agee = f"{agee}rd"
|
| 47 |
else:
|
| 48 |
-
agee
|
|
|
|
| 49 |
U = await JJK.get_chat_member(chat_id=j,user_id=i["user_id"])
|
| 50 |
wish = choice(birthday_wish)
|
| 51 |
if U.status in [ChatMemberStatus.MEMBER,ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.OWNER]:
|
|
|
|
| 38 |
agee = ""
|
| 39 |
if i["is_year"]:
|
| 40 |
agee = curr.year - dob.year
|
| 41 |
+
suffix = {1: 'st', 2: 'nd', 3: 'rd'}
|
| 42 |
+
if int(agee/10) == 1:
|
| 43 |
+
suf = "th"
|
|
|
|
|
|
|
|
|
|
| 44 |
else:
|
| 45 |
+
suffix.get((agee%10), "th")
|
| 46 |
+
agee = f"{agee}{suf}"
|
| 47 |
U = await JJK.get_chat_member(chat_id=j,user_id=i["user_id"])
|
| 48 |
wish = choice(birthday_wish)
|
| 49 |
if U.status in [ChatMemberStatus.MEMBER,ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.OWNER]:
|
Powers/plugins/start.py
CHANGED
|
@@ -14,6 +14,7 @@ from Powers import (DEV_USERS, HELP_COMMANDS, LOGGER, OWNER_ID, PREFIX_HANDLER,
|
|
| 14 |
PYROGRAM_VERSION, PYTHON_VERSION, SUDO_USERS, UPTIME,
|
| 15 |
VERSION, WHITELIST_USERS)
|
| 16 |
from Powers.bot_class import Gojo
|
|
|
|
| 17 |
from Powers.utils.custom_filters import command
|
| 18 |
from Powers.utils.extras import StartPic
|
| 19 |
from Powers.utils.kbhelpers import ikb
|
|
@@ -69,7 +70,8 @@ async def start(c: Gojo, m: Message):
|
|
| 69 |
|
| 70 |
if m.chat.type == ChatType.PRIVATE:
|
| 71 |
if len(m.text.strip().split()) > 1:
|
| 72 |
-
|
|
|
|
| 73 |
|
| 74 |
if help_option.startswith("note") and (
|
| 75 |
help_option not in ("note", "notes")
|
|
@@ -83,9 +85,7 @@ async def start(c: Gojo, m: Message):
|
|
| 83 |
|
| 84 |
help_msg, help_kb = await get_help_msg(c, m, help_option)
|
| 85 |
|
| 86 |
-
if
|
| 87 |
-
return
|
| 88 |
-
elif help_msg:
|
| 89 |
await m.reply_photo(
|
| 90 |
photo=str(choice(StartPic)),
|
| 91 |
caption=help_msg,
|
|
@@ -94,8 +94,8 @@ async def start(c: Gojo, m: Message):
|
|
| 94 |
quote=True,
|
| 95 |
)
|
| 96 |
return
|
| 97 |
-
if len(
|
| 98 |
-
if
|
| 99 |
await m.reply_photo(
|
| 100 |
photo=str(choice(StartPic)),
|
| 101 |
caption=help_msg,
|
|
@@ -104,9 +104,9 @@ async def start(c: Gojo, m: Message):
|
|
| 104 |
quote=True,
|
| 105 |
)
|
| 106 |
return
|
| 107 |
-
elif
|
| 108 |
decoded = encode_decode(
|
| 109 |
-
|
| 110 |
decode = decoded.split(":")
|
| 111 |
chat = decode[0]
|
| 112 |
user = decode[1]
|
|
@@ -115,9 +115,25 @@ async def start(c: Gojo, m: Message):
|
|
| 115 |
return
|
| 116 |
try:
|
| 117 |
await c.unban_chat_member(int(chat), int(user))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
try:
|
| 119 |
-
|
| 120 |
-
except
|
| 121 |
pass
|
| 122 |
return
|
| 123 |
except Exception:
|
|
|
|
| 14 |
PYROGRAM_VERSION, PYTHON_VERSION, SUDO_USERS, UPTIME,
|
| 15 |
VERSION, WHITELIST_USERS)
|
| 16 |
from Powers.bot_class import Gojo
|
| 17 |
+
from Powers.database.captcha_db import CAPTCHA_DATA
|
| 18 |
from Powers.utils.custom_filters import command
|
| 19 |
from Powers.utils.extras import StartPic
|
| 20 |
from Powers.utils.kbhelpers import ikb
|
|
|
|
| 70 |
|
| 71 |
if m.chat.type == ChatType.PRIVATE:
|
| 72 |
if len(m.text.strip().split()) > 1:
|
| 73 |
+
arg = m.text.split(None, 1)[1]
|
| 74 |
+
help_option = arg.lower()
|
| 75 |
|
| 76 |
if help_option.startswith("note") and (
|
| 77 |
help_option not in ("note", "notes")
|
|
|
|
| 85 |
|
| 86 |
help_msg, help_kb = await get_help_msg(c, m, help_option)
|
| 87 |
|
| 88 |
+
if help_msg:
|
|
|
|
|
|
|
| 89 |
await m.reply_photo(
|
| 90 |
photo=str(choice(StartPic)),
|
| 91 |
caption=help_msg,
|
|
|
|
| 94 |
quote=True,
|
| 95 |
)
|
| 96 |
return
|
| 97 |
+
if len(arg.split("_", 1)) >= 2:
|
| 98 |
+
if arg.split("_")[1] == "help":
|
| 99 |
await m.reply_photo(
|
| 100 |
photo=str(choice(StartPic)),
|
| 101 |
caption=help_msg,
|
|
|
|
| 104 |
quote=True,
|
| 105 |
)
|
| 106 |
return
|
| 107 |
+
elif arg.split("_", 1)[0] == "qr":
|
| 108 |
decoded = encode_decode(
|
| 109 |
+
arg.split("_", 1)[1], "decode")
|
| 110 |
decode = decoded.split(":")
|
| 111 |
chat = decode[0]
|
| 112 |
user = decode[1]
|
|
|
|
| 115 |
return
|
| 116 |
try:
|
| 117 |
await c.unban_chat_member(int(chat), int(user))
|
| 118 |
+
msg = CAPTCHA_DATA().del_message_id(chat, user)
|
| 119 |
+
try:
|
| 120 |
+
chat_ = await c.get_chat(chat)
|
| 121 |
+
kb = ikb(
|
| 122 |
+
[
|
| 123 |
+
[
|
| 124 |
+
"Link to chat",
|
| 125 |
+
f"{chat_.invite_link}",
|
| 126 |
+
"url"
|
| 127 |
+
]
|
| 128 |
+
]
|
| 129 |
+
)
|
| 130 |
+
except:
|
| 131 |
+
chat_ = False
|
| 132 |
+
kb = None
|
| 133 |
+
await m.reply_text("You can now talk in the chat", reply_markup=kb)
|
| 134 |
try:
|
| 135 |
+
await c.delete_messages(chat, msg)
|
| 136 |
+
except:
|
| 137 |
pass
|
| 138 |
return
|
| 139 |
except Exception:
|
Powers/plugins/stickers.py
CHANGED
|
@@ -173,7 +173,6 @@ async def kang(c:Gojo, m: Message):
|
|
| 173 |
volume += 1
|
| 174 |
continue
|
| 175 |
try:
|
| 176 |
-
print(sticker_set)
|
| 177 |
await add_sticker_to_set(c,sticker_set,sticker)
|
| 178 |
packname_found = True
|
| 179 |
except StickerEmojiInvalid:
|
|
@@ -326,7 +325,7 @@ async def get_sticker_from_file(c: Gojo, m: Message):
|
|
| 326 |
upp = await repl.download()
|
| 327 |
up = toimage(upp,is_direc=True)
|
| 328 |
await x.delete()
|
| 329 |
-
await m.
|
| 330 |
os.remove(up)
|
| 331 |
return
|
| 332 |
elif repl.photo:
|
|
|
|
| 173 |
volume += 1
|
| 174 |
continue
|
| 175 |
try:
|
|
|
|
| 176 |
await add_sticker_to_set(c,sticker_set,sticker)
|
| 177 |
packname_found = True
|
| 178 |
except StickerEmojiInvalid:
|
|
|
|
| 325 |
upp = await repl.download()
|
| 326 |
up = toimage(upp,is_direc=True)
|
| 327 |
await x.delete()
|
| 328 |
+
await m.reply_document(up, caption=Caption)
|
| 329 |
os.remove(up)
|
| 330 |
return
|
| 331 |
elif repl.photo:
|
Powers/utils/captcha_helper.py
CHANGED
|
@@ -2,20 +2,17 @@ from random import choice, randint, randrange
|
|
| 2 |
|
| 3 |
import qrcode
|
| 4 |
from captcha.image import ImageCaptcha
|
| 5 |
-
from pyrogram.types import InlineKeyboardButton as IKB
|
| 6 |
-
from pyrogram.types import InlineKeyboardMarkup as IKM
|
| 7 |
|
| 8 |
from Powers.database.captcha_db import CAPTCHA_DATA
|
| 9 |
from Powers.utils.string import encode_decode
|
| 10 |
-
from Powers.vars import Config
|
| 11 |
|
| 12 |
-
initial = f"t.me/{Config.BOT_USERNAME}?start=qrcaptcha_"
|
| 13 |
captchaa = CAPTCHA_DATA()
|
| 14 |
|
| 15 |
|
| 16 |
-
async def get_qr_captcha(chat, user):
|
|
|
|
| 17 |
encode = f"{chat}:{user}"
|
| 18 |
-
encoded = encode_decode(encode)
|
| 19 |
final = initial+encoded
|
| 20 |
qr = qrcode.make(final)
|
| 21 |
name = f"captcha_verification{chat}_{user}.png"
|
|
@@ -42,7 +39,7 @@ def genrator():
|
|
| 42 |
str_ = ""
|
| 43 |
while len(str_) != 4:
|
| 44 |
OwO = choice(list_)
|
| 45 |
-
str_ += OwO
|
| 46 |
return str_
|
| 47 |
|
| 48 |
|
|
@@ -55,4 +52,4 @@ async def get_image_captcha(chat, user):
|
|
| 55 |
cap = image.generate(str_)
|
| 56 |
image.write(str_, name)
|
| 57 |
|
| 58 |
-
return name, str_
|
|
|
|
| 2 |
|
| 3 |
import qrcode
|
| 4 |
from captcha.image import ImageCaptcha
|
|
|
|
|
|
|
| 5 |
|
| 6 |
from Powers.database.captcha_db import CAPTCHA_DATA
|
| 7 |
from Powers.utils.string import encode_decode
|
|
|
|
| 8 |
|
|
|
|
| 9 |
captchaa = CAPTCHA_DATA()
|
| 10 |
|
| 11 |
|
| 12 |
+
async def get_qr_captcha(chat, user, username):
|
| 13 |
+
initial = f"t.me/{username}?start=qr_"
|
| 14 |
encode = f"{chat}:{user}"
|
| 15 |
+
encoded = await encode_decode(encode)
|
| 16 |
final = initial+encoded
|
| 17 |
qr = qrcode.make(final)
|
| 18 |
name = f"captcha_verification{chat}_{user}.png"
|
|
|
|
| 39 |
str_ = ""
|
| 40 |
while len(str_) != 4:
|
| 41 |
OwO = choice(list_)
|
| 42 |
+
str_ += str(OwO)
|
| 43 |
return str_
|
| 44 |
|
| 45 |
|
|
|
|
| 52 |
cap = image.generate(str_)
|
| 53 |
image.write(str_, name)
|
| 54 |
|
| 55 |
+
return name, str_
|
Powers/utils/custom_filters.py
CHANGED
|
@@ -14,6 +14,7 @@ from Powers.bot_class import Gojo
|
|
| 14 |
from Powers.database.afk_db import AFK
|
| 15 |
from Powers.database.approve_db import Approve
|
| 16 |
from Powers.database.autojoin_db import AUTOJOIN
|
|
|
|
| 17 |
from Powers.database.disable_db import Disabling
|
| 18 |
from Powers.database.flood_db import Floods
|
| 19 |
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
|
|
@@ -329,12 +330,19 @@ async def afk_check_filter(_, __, m: Message):
|
|
| 329 |
return False
|
| 330 |
|
| 331 |
afk = AFK()
|
| 332 |
-
user = m.from_user.id
|
| 333 |
chat = m.chat.id
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 334 |
|
| 335 |
is_afk = afk.check_afk(chat, user)
|
| 336 |
|
| 337 |
-
if not is_afk:
|
| 338 |
return False
|
| 339 |
else:
|
| 340 |
return True
|
|
@@ -354,19 +362,36 @@ async def flood_check_filter(_, __, m: Message):
|
|
| 354 |
u_id = m.from_user.id
|
| 355 |
c_id = m.chat.id
|
| 356 |
is_flood = Flood.is_chat(c_id)
|
| 357 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 358 |
app_users = Approve(m.chat.id).list_approved()
|
| 359 |
SUDO_LEVEL = DEV_USERS.union(SUDO_USERS)
|
| 360 |
|
| 361 |
-
if
|
| 362 |
return False
|
| 363 |
|
|
|
|
|
|
|
|
|
|
| 364 |
elif u_id in {i[0] for i in app_users}:
|
| 365 |
return False
|
| 366 |
|
| 367 |
else:
|
| 368 |
return True
|
| 369 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 370 |
flood_filter = create(flood_check_filter)
|
| 371 |
afk_filter = create(afk_check_filter)
|
| 372 |
auto_join_filter = create(auto_join_check_filter)
|
|
|
|
| 14 |
from Powers.database.afk_db import AFK
|
| 15 |
from Powers.database.approve_db import Approve
|
| 16 |
from Powers.database.autojoin_db import AUTOJOIN
|
| 17 |
+
from Powers.database.captcha_db import CAPTCHA
|
| 18 |
from Powers.database.disable_db import Disabling
|
| 19 |
from Powers.database.flood_db import Floods
|
| 20 |
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
|
|
|
|
| 330 |
return False
|
| 331 |
|
| 332 |
afk = AFK()
|
|
|
|
| 333 |
chat = m.chat.id
|
| 334 |
+
is_repl_afk = None
|
| 335 |
+
if m.reply_to_message:
|
| 336 |
+
repl_user = m.reply_to_message.from_user
|
| 337 |
+
if repl_user:
|
| 338 |
+
repl_user = m.reply_to_message.from_user.id
|
| 339 |
+
is_repl_afk = afk.check_afk(chat, repl_user)
|
| 340 |
+
|
| 341 |
+
user = m.from_user.id
|
| 342 |
|
| 343 |
is_afk = afk.check_afk(chat, user)
|
| 344 |
|
| 345 |
+
if not (is_afk or is_repl_afk):
|
| 346 |
return False
|
| 347 |
else:
|
| 348 |
return True
|
|
|
|
| 362 |
u_id = m.from_user.id
|
| 363 |
c_id = m.chat.id
|
| 364 |
is_flood = Flood.is_chat(c_id)
|
| 365 |
+
if not is_flood:
|
| 366 |
+
return False
|
| 367 |
+
try:
|
| 368 |
+
admin_group = {i[0] for i in ADMIN_CACHE[m.chat.id]}
|
| 369 |
+
except KeyError:
|
| 370 |
+
admin_group = {
|
| 371 |
+
i[0] for i in await admin_cache_reload(m, "custom_filter_update")
|
| 372 |
+
}
|
| 373 |
app_users = Approve(m.chat.id).list_approved()
|
| 374 |
SUDO_LEVEL = DEV_USERS.union(SUDO_USERS)
|
| 375 |
|
| 376 |
+
if u_id in SUDO_LEVEL:
|
| 377 |
return False
|
| 378 |
|
| 379 |
+
elif u_id in admin_group:
|
| 380 |
+
return False
|
| 381 |
+
|
| 382 |
elif u_id in {i[0] for i in app_users}:
|
| 383 |
return False
|
| 384 |
|
| 385 |
else:
|
| 386 |
return True
|
| 387 |
|
| 388 |
+
async def captcha_filt(_, __, m: Message):
|
| 389 |
+
try:
|
| 390 |
+
return CAPTCHA().is_captcha(m.chat.id)
|
| 391 |
+
except:
|
| 392 |
+
return False
|
| 393 |
+
|
| 394 |
+
captcha_filter = create(captcha_filt)
|
| 395 |
flood_filter = create(flood_check_filter)
|
| 396 |
afk_filter = create(afk_check_filter)
|
| 397 |
auto_join_filter = create(auto_join_check_filter)
|
Powers/utils/sticker_help.py
CHANGED
|
@@ -349,14 +349,14 @@ async def draw_meme(image_path: str, text: str, sticker: bool, fiill: str) -> li
|
|
| 349 |
|
| 350 |
|
| 351 |
def toimage(image, filename=None, is_direc=False):
|
| 352 |
-
filename = filename if filename else "gojo.
|
| 353 |
if is_direc:
|
| 354 |
os.rename(image, filename)
|
| 355 |
return filename
|
| 356 |
img = Image.open(image)
|
| 357 |
if img.mode != "RGB":
|
| 358 |
img = img.convert("RGB")
|
| 359 |
-
img.save(filename, "
|
| 360 |
os.remove(image)
|
| 361 |
return filename
|
| 362 |
|
|
|
|
| 349 |
|
| 350 |
|
| 351 |
def toimage(image, filename=None, is_direc=False):
|
| 352 |
+
filename = filename if filename else "gojo.png"
|
| 353 |
if is_direc:
|
| 354 |
os.rename(image, filename)
|
| 355 |
return filename
|
| 356 |
img = Image.open(image)
|
| 357 |
if img.mode != "RGB":
|
| 358 |
img = img.convert("RGB")
|
| 359 |
+
img.save(filename, "png")
|
| 360 |
os.remove(image)
|
| 361 |
return filename
|
| 362 |
|
requirements.txt
CHANGED
|
@@ -16,7 +16,7 @@ pillow == 10.1.0
|
|
| 16 |
prettyconf==2.2.1
|
| 17 |
pyaes==1.6.1
|
| 18 |
pymongo==4.6.1
|
| 19 |
-
git+https://github.com/KurimuzonAkuma/[email protected].
|
| 20 |
pysocks==1.7.1
|
| 21 |
python-dateutil==2.8.2
|
| 22 |
pytube==15.0.0
|
|
|
|
| 16 |
prettyconf==2.2.1
|
| 17 |
pyaes==1.6.1
|
| 18 |
pymongo==4.6.1
|
| 19 |
+
git+https://github.com/KurimuzonAkuma/[email protected].32
|
| 20 |
pysocks==1.7.1
|
| 21 |
python-dateutil==2.8.2
|
| 22 |
pytube==15.0.0
|