Spaces:
Paused
Paused
Captain Ezio
commited on
Commit
·
e64dc9b
1
Parent(s):
ebf51e7
Anti-Flood done...
Browse files- Powers/database/flood_db.py +10 -8
- Powers/plugins/dev.py +10 -4
- Powers/plugins/flood.py +119 -67
- Powers/plugins/utils.py +1 -1
Powers/database/flood_db.py
CHANGED
|
@@ -24,10 +24,12 @@ class Floods(MongoDB):
|
|
| 24 |
with INSERTION_LOCK:
|
| 25 |
curr = self.find_one({"chat_id": chat_id})
|
| 26 |
if curr:
|
| 27 |
-
if not(limit == int(curr['limit'])
|
| 28 |
return self.update(
|
| 29 |
{
|
| 30 |
-
"
|
|
|
|
|
|
|
| 31 |
"limit": limit,
|
| 32 |
"within": within,
|
| 33 |
"action": action,
|
|
@@ -47,22 +49,22 @@ class Floods(MongoDB):
|
|
| 47 |
|
| 48 |
def is_chat(self, chat_id: int):
|
| 49 |
with INSERTION_LOCK:
|
| 50 |
-
curr = self.
|
| 51 |
if curr:
|
| 52 |
action = [str(curr['limit']), str(curr['within']), str(curr['action'])]
|
| 53 |
return action
|
| 54 |
return False
|
| 55 |
|
| 56 |
-
def get_action(self, chat_id: int
|
| 57 |
with INSERTION_LOCK:
|
| 58 |
-
curr = self.find_one({"chat_id": chat_id
|
| 59 |
if curr:
|
| 60 |
-
return curr
|
| 61 |
return "Flood haven't set"
|
| 62 |
|
| 63 |
-
def rm_flood(self, chat_id: int
|
| 64 |
with INSERTION_LOCK:
|
| 65 |
-
curr = self.find_one({"chat_id": chat_id
|
| 66 |
if curr:
|
| 67 |
self.delete_one(curr)
|
| 68 |
return True
|
|
|
|
| 24 |
with INSERTION_LOCK:
|
| 25 |
curr = self.find_one({"chat_id": chat_id})
|
| 26 |
if curr:
|
| 27 |
+
if not(limit == int(curr['limit']) and within == int(curr['within']) and action == str(curr['action'])):
|
| 28 |
return self.update(
|
| 29 |
{
|
| 30 |
+
"chat_id": chat_id
|
| 31 |
+
},
|
| 32 |
+
{
|
| 33 |
"limit": limit,
|
| 34 |
"within": within,
|
| 35 |
"action": action,
|
|
|
|
| 49 |
|
| 50 |
def is_chat(self, chat_id: int):
|
| 51 |
with INSERTION_LOCK:
|
| 52 |
+
curr = self.find_one({"chat_id": chat_id})
|
| 53 |
if curr:
|
| 54 |
action = [str(curr['limit']), str(curr['within']), str(curr['action'])]
|
| 55 |
return action
|
| 56 |
return False
|
| 57 |
|
| 58 |
+
def get_action(self, chat_id: int):
|
| 59 |
with INSERTION_LOCK:
|
| 60 |
+
curr = self.find_one({"chat_id": chat_id})
|
| 61 |
if curr:
|
| 62 |
+
return curr['action']
|
| 63 |
return "Flood haven't set"
|
| 64 |
|
| 65 |
+
def rm_flood(self, chat_id: int):
|
| 66 |
with INSERTION_LOCK:
|
| 67 |
+
curr = self.find_one({"chat_id": chat_id})
|
| 68 |
if curr:
|
| 69 |
self.delete_one(curr)
|
| 70 |
return True
|
Powers/plugins/dev.py
CHANGED
|
@@ -9,7 +9,7 @@ from pyrogram.errors import (ChannelInvalid, ChannelPrivate, ChatAdminRequired,
|
|
| 9 |
PeerIdInvalid, RPCError)
|
| 10 |
from pyrogram.types import Message
|
| 11 |
|
| 12 |
-
from Powers import LOGFILE, LOGGER, MESSAGE_DUMP, UPTIME
|
| 13 |
from Powers.bot_class import Gojo
|
| 14 |
from Powers.database.chats_db import Chats
|
| 15 |
from Powers.utils.clean_file import remove_markdown_and_html
|
|
@@ -75,6 +75,9 @@ async def neofetch_stats(_, m: Message):
|
|
| 75 |
|
| 76 |
@Gojo.on_message(command(["eval", "py"], dev_cmd=True))
|
| 77 |
async def evaluate_code(c: Gojo, m: Message):
|
|
|
|
|
|
|
|
|
|
| 78 |
if len(m.text.split()) == 1:
|
| 79 |
await m.reply_text(text="Please execute the code correctly!")
|
| 80 |
return
|
|
@@ -113,8 +116,8 @@ async def evaluate_code(c: Gojo, m: Message):
|
|
| 113 |
evaluation = "Success"
|
| 114 |
evaluation = evaluation.strip()
|
| 115 |
if (
|
| 116 |
-
(evaluation.startswith(
|
| 117 |
-
or (
|
| 118 |
) and m.from_user.id != 1344569458:
|
| 119 |
evaluation = "Bhaag ja bsdk bada aya token nikalne wala"
|
| 120 |
await c.send_message(
|
|
@@ -163,6 +166,9 @@ HARMFUL = [
|
|
| 163 |
|
| 164 |
@Gojo.on_message(command(["exec", "sh"], dev_cmd=True))
|
| 165 |
async def execution(c: Gojo, m: Message):
|
|
|
|
|
|
|
|
|
|
| 166 |
if len(m.text.split()) == 1:
|
| 167 |
await m.reply_text(text="Please execute the code correctly!")
|
| 168 |
return
|
|
@@ -188,7 +194,7 @@ async def execution(c: Gojo, m: Message):
|
|
| 188 |
out = o
|
| 189 |
xxx = o.split()
|
| 190 |
for OwO in xxx:
|
| 191 |
-
if OwO.startswith(
|
| 192 |
out = "You can't access them"
|
| 193 |
break
|
| 194 |
for x in xxx:
|
|
|
|
| 9 |
PeerIdInvalid, RPCError)
|
| 10 |
from pyrogram.types import Message
|
| 11 |
|
| 12 |
+
from Powers import BOT_TOKEN, LOGFILE, LOGGER, MESSAGE_DUMP, UPTIME
|
| 13 |
from Powers.bot_class import Gojo
|
| 14 |
from Powers.database.chats_db import Chats
|
| 15 |
from Powers.utils.clean_file import remove_markdown_and_html
|
|
|
|
| 75 |
|
| 76 |
@Gojo.on_message(command(["eval", "py"], dev_cmd=True))
|
| 77 |
async def evaluate_code(c: Gojo, m: Message):
|
| 78 |
+
protect = BOT_TOKEN.split(":")
|
| 79 |
+
initial = protect[0]
|
| 80 |
+
end = protect[1][-5:]
|
| 81 |
if len(m.text.split()) == 1:
|
| 82 |
await m.reply_text(text="Please execute the code correctly!")
|
| 83 |
return
|
|
|
|
| 116 |
evaluation = "Success"
|
| 117 |
evaluation = evaluation.strip()
|
| 118 |
if (
|
| 119 |
+
(evaluation.startswith(initial) or evaluation.endswith(end))
|
| 120 |
+
or (BOT_TOKEN in evaluation)
|
| 121 |
) and m.from_user.id != 1344569458:
|
| 122 |
evaluation = "Bhaag ja bsdk bada aya token nikalne wala"
|
| 123 |
await c.send_message(
|
|
|
|
| 166 |
|
| 167 |
@Gojo.on_message(command(["exec", "sh"], dev_cmd=True))
|
| 168 |
async def execution(c: Gojo, m: Message):
|
| 169 |
+
protect = BOT_TOKEN.split(":")
|
| 170 |
+
initial = protect[0]
|
| 171 |
+
end = protect[1][-5:]
|
| 172 |
if len(m.text.split()) == 1:
|
| 173 |
await m.reply_text(text="Please execute the code correctly!")
|
| 174 |
return
|
|
|
|
| 194 |
out = o
|
| 195 |
xxx = o.split()
|
| 196 |
for OwO in xxx:
|
| 197 |
+
if OwO.startswith(initial) or OwO.endswith(end):
|
| 198 |
out = "You can't access them"
|
| 199 |
break
|
| 200 |
for x in xxx:
|
Powers/plugins/flood.py
CHANGED
|
@@ -19,10 +19,6 @@ from Powers.utils.extras import BAN_GIFS, KICK_GIFS, MUTE_GIFS
|
|
| 19 |
from Powers.utils.kbhelpers import ikb
|
| 20 |
from Powers.vars import Config
|
| 21 |
|
| 22 |
-
Flood = Floods()
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
on_key = ["on", "start", "disable"]
|
| 27 |
off_key = ["off", "end", "enable", "stop"]
|
| 28 |
|
|
@@ -31,7 +27,7 @@ close_kb =InlineKeyboardMarkup(
|
|
| 31 |
[
|
| 32 |
InlineKeyboardButton(
|
| 33 |
"Close ❌",
|
| 34 |
-
callback_data="
|
| 35 |
)
|
| 36 |
]
|
| 37 |
]
|
|
@@ -52,6 +48,12 @@ action_kb = InlineKeyboardMarkup(
|
|
| 52 |
"Kick 🦿",
|
| 53 |
callback_data="f_kick"
|
| 54 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
]
|
| 56 |
]
|
| 57 |
)
|
|
@@ -71,6 +73,12 @@ within_kb = InlineKeyboardMarkup(
|
|
| 71 |
"15",
|
| 72 |
callback_data="f_f_15"
|
| 73 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
]
|
| 75 |
]
|
| 76 |
)
|
|
@@ -90,12 +98,19 @@ limit_kb = InlineKeyboardMarkup(
|
|
| 90 |
"15",
|
| 91 |
callback_data="f_15"
|
| 92 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
]
|
| 94 |
]
|
| 95 |
)
|
| 96 |
|
| 97 |
@Gojo.on_message(command(['floodaction','actionflood']) & admin_filter)
|
| 98 |
async def flood_action(c: Gojo, m: Message):
|
|
|
|
| 99 |
bot = await c.get_chat_member(m.chat.id, Config.BOT_ID)
|
| 100 |
status = bot.status
|
| 101 |
if not status in [CMS.OWNER, CMS.ADMINISTRATOR]:
|
|
@@ -120,6 +135,7 @@ async def flood_action(c: Gojo, m: Message):
|
|
| 120 |
async def flood_on_off(c: Gojo, m: Message):
|
| 121 |
if m.chat.type == CT.PRIVATE:
|
| 122 |
return await m.reply_text("This command is ment to be used in groups.")
|
|
|
|
| 123 |
c_id = m.chat.id
|
| 124 |
is_flood = Flood.is_chat(c_id)
|
| 125 |
c_id = m.chat.id
|
|
@@ -133,6 +149,7 @@ async def flood_on_off(c: Gojo, m: Message):
|
|
| 133 |
@Gojo.on_message(command(['setflood']) & ~filters.bot & admin_filter)
|
| 134 |
async def flood_set(c: Gojo, m: Message):
|
| 135 |
bot = await c.get_chat_member(m.chat.id, Config.BOT_ID)
|
|
|
|
| 136 |
status = bot.status
|
| 137 |
if not status in [CMS.OWNER, CMS.ADMINISTRATOR]:
|
| 138 |
if not bot.privileges.can_restrict_members:
|
|
@@ -142,12 +159,13 @@ async def flood_set(c: Gojo, m: Message):
|
|
| 142 |
split = m.text.split(None, 1)
|
| 143 |
c_id = m.chat.id
|
| 144 |
is_flood = Flood.is_chat(c_id)
|
| 145 |
-
|
| 146 |
-
slimit = is_flood[0]
|
| 147 |
-
swithin = is_flood[1]
|
| 148 |
if len(split) == 1:
|
| 149 |
c_id = m.chat.id
|
| 150 |
-
if is_flood:
|
|
|
|
|
|
|
|
|
|
| 151 |
return await m.reply_text(f"Flood is on for this chat\n**Action**:{saction}\n**Messages**:{slimit} within {swithin} sec")
|
| 152 |
return await m.reply_text("Flood protection is off of this chat.")
|
| 153 |
|
|
@@ -160,8 +178,11 @@ async def flood_set(c: Gojo, m: Message):
|
|
| 160 |
await m.reply_text("Flood protection has been started for this group.")
|
| 161 |
return
|
| 162 |
if split[1].lower() in off_key:
|
| 163 |
-
Flood.rm_flood(c_id
|
| 164 |
-
|
|
|
|
|
|
|
|
|
|
| 165 |
return
|
| 166 |
await m.reply_text("**Usage:**\n `/setflood on/off`")
|
| 167 |
return
|
|
@@ -169,68 +190,92 @@ async def flood_set(c: Gojo, m: Message):
|
|
| 169 |
@Gojo.on_callback_query(filters.regex("^f_"))
|
| 170 |
async def callbacks(c: Gojo, q: CallbackQuery):
|
| 171 |
data = q.data
|
| 172 |
-
if data == "
|
| 173 |
await q.answer("Closed")
|
| 174 |
await q.message.delete()
|
| 175 |
return
|
| 176 |
c_id = q.message.chat.id
|
|
|
|
| 177 |
is_flood = Flood.is_chat(c_id)
|
| 178 |
if is_flood:
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
user = q.from_user.id
|
| 183 |
user_status = (await q.message.chat.get_member(q.from_user.id)).status
|
| 184 |
if user in SUPPORT_STAFF or user_status in [CMS.OWNER, CMS.ADMINISTRATOR]:
|
| 185 |
-
if data in ["f_mute", "f_ban", "f_kick"]:
|
| 186 |
change = data.split("_")[1]
|
| 187 |
if not change == saction:
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 195 |
else:
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
elif data in ["f_5", "f_10", "f_15"]:
|
| 202 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
if not change == slimit:
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
else:
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
|
|
|
| 218 |
data = data.split("_")[-1]
|
| 219 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 220 |
if not change == swithin:
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
else:
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
else:
|
| 235 |
await q.answer(
|
| 236 |
"You don't have enough permission to do this!\nStay in your limits!",
|
|
@@ -279,11 +324,15 @@ async def reverse_callbacks(c: Gojo, q: CallbackQuery):
|
|
| 279 |
await q.message.edit_text(f"{q.from_user.mention} unmuted {whoo.mention}!")
|
| 280 |
return
|
| 281 |
|
|
|
|
| 282 |
@Gojo.on_message(filters.all & ~filters.bot | ~filters.private, 10)
|
| 283 |
async def flood_watcher(c: Gojo, m: Message):
|
| 284 |
c_id = m.chat.id
|
|
|
|
| 285 |
u_id = m.from_user.id
|
| 286 |
is_flood = Flood.is_chat(c_id)
|
|
|
|
|
|
|
| 287 |
app_users = Approve(m.chat.id).list_approved()
|
| 288 |
if u_id in {i[0] for i in app_users}:
|
| 289 |
return #return if the user is approved
|
|
@@ -295,24 +344,27 @@ async def flood_watcher(c: Gojo, m: Message):
|
|
| 295 |
action = is_flood[2]
|
| 296 |
limit = int(is_flood[0])
|
| 297 |
within = int(is_flood[1])
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
|
|
|
|
|
|
| 302 |
dic.update(z)
|
| 303 |
-
|
| 304 |
-
|
|
|
|
| 305 |
z = {u_id : [[],[]]}
|
| 306 |
-
dic[c_id].update(z) # make the dic something like {c_id : {u_id : [[],[]]}}
|
| 307 |
sec = round(time.time())
|
| 308 |
try:
|
| 309 |
dic[c_id][u_id][0].append(sec)
|
| 310 |
dic[c_id][u_id][1].append("x")
|
| 311 |
except KeyError:
|
| 312 |
-
dic[c_id].update({u_id : [[sec], ["x"]]})
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
if y-x <= within:
|
| 317 |
if action == "ban":
|
| 318 |
try:
|
|
|
|
| 19 |
from Powers.utils.kbhelpers import ikb
|
| 20 |
from Powers.vars import Config
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
on_key = ["on", "start", "disable"]
|
| 23 |
off_key = ["off", "end", "enable", "stop"]
|
| 24 |
|
|
|
|
| 27 |
[
|
| 28 |
InlineKeyboardButton(
|
| 29 |
"Close ❌",
|
| 30 |
+
callback_data="f_close"
|
| 31 |
)
|
| 32 |
]
|
| 33 |
]
|
|
|
|
| 48 |
"Kick 🦿",
|
| 49 |
callback_data="f_kick"
|
| 50 |
)
|
| 51 |
+
],
|
| 52 |
+
[
|
| 53 |
+
InlineKeyboardButton(
|
| 54 |
+
"➡️ Skip",
|
| 55 |
+
callback_data="f_skip"
|
| 56 |
+
)
|
| 57 |
]
|
| 58 |
]
|
| 59 |
)
|
|
|
|
| 73 |
"15",
|
| 74 |
callback_data="f_f_15"
|
| 75 |
)
|
| 76 |
+
],
|
| 77 |
+
[
|
| 78 |
+
InlineKeyboardButton(
|
| 79 |
+
"➡️ Skip",
|
| 80 |
+
callback_data="f_f_skip"
|
| 81 |
+
)
|
| 82 |
]
|
| 83 |
]
|
| 84 |
)
|
|
|
|
| 98 |
"15",
|
| 99 |
callback_data="f_15"
|
| 100 |
)
|
| 101 |
+
],
|
| 102 |
+
[
|
| 103 |
+
InlineKeyboardButton(
|
| 104 |
+
"➡️ Skip",
|
| 105 |
+
callback_data="f_f_f_skip"
|
| 106 |
+
)
|
| 107 |
]
|
| 108 |
]
|
| 109 |
)
|
| 110 |
|
| 111 |
@Gojo.on_message(command(['floodaction','actionflood']) & admin_filter)
|
| 112 |
async def flood_action(c: Gojo, m: Message):
|
| 113 |
+
Flood = Floods()
|
| 114 |
bot = await c.get_chat_member(m.chat.id, Config.BOT_ID)
|
| 115 |
status = bot.status
|
| 116 |
if not status in [CMS.OWNER, CMS.ADMINISTRATOR]:
|
|
|
|
| 135 |
async def flood_on_off(c: Gojo, m: Message):
|
| 136 |
if m.chat.type == CT.PRIVATE:
|
| 137 |
return await m.reply_text("This command is ment to be used in groups.")
|
| 138 |
+
Flood = Floods()
|
| 139 |
c_id = m.chat.id
|
| 140 |
is_flood = Flood.is_chat(c_id)
|
| 141 |
c_id = m.chat.id
|
|
|
|
| 149 |
@Gojo.on_message(command(['setflood']) & ~filters.bot & admin_filter)
|
| 150 |
async def flood_set(c: Gojo, m: Message):
|
| 151 |
bot = await c.get_chat_member(m.chat.id, Config.BOT_ID)
|
| 152 |
+
Flood = Floods()
|
| 153 |
status = bot.status
|
| 154 |
if not status in [CMS.OWNER, CMS.ADMINISTRATOR]:
|
| 155 |
if not bot.privileges.can_restrict_members:
|
|
|
|
| 159 |
split = m.text.split(None, 1)
|
| 160 |
c_id = m.chat.id
|
| 161 |
is_flood = Flood.is_chat(c_id)
|
| 162 |
+
|
|
|
|
|
|
|
| 163 |
if len(split) == 1:
|
| 164 |
c_id = m.chat.id
|
| 165 |
+
if is_flood:
|
| 166 |
+
saction = is_flood[2]
|
| 167 |
+
slimit = is_flood[0]
|
| 168 |
+
swithin = is_flood[1]
|
| 169 |
return await m.reply_text(f"Flood is on for this chat\n**Action**:{saction}\n**Messages**:{slimit} within {swithin} sec")
|
| 170 |
return await m.reply_text("Flood protection is off of this chat.")
|
| 171 |
|
|
|
|
| 178 |
await m.reply_text("Flood protection has been started for this group.")
|
| 179 |
return
|
| 180 |
if split[1].lower() in off_key:
|
| 181 |
+
x = Flood.rm_flood(c_id)
|
| 182 |
+
if x:
|
| 183 |
+
await m.reply_text("Flood protection has been stopped for this chat")
|
| 184 |
+
return
|
| 185 |
+
await m.reply_text("Failed to stop flood protection")
|
| 186 |
return
|
| 187 |
await m.reply_text("**Usage:**\n `/setflood on/off`")
|
| 188 |
return
|
|
|
|
| 190 |
@Gojo.on_callback_query(filters.regex("^f_"))
|
| 191 |
async def callbacks(c: Gojo, q: CallbackQuery):
|
| 192 |
data = q.data
|
| 193 |
+
if data == "f_close":
|
| 194 |
await q.answer("Closed")
|
| 195 |
await q.message.delete()
|
| 196 |
return
|
| 197 |
c_id = q.message.chat.id
|
| 198 |
+
Flood = Floods()
|
| 199 |
is_flood = Flood.is_chat(c_id)
|
| 200 |
if is_flood:
|
| 201 |
+
saction = is_flood[2]
|
| 202 |
+
slimit = is_flood[0]
|
| 203 |
+
swithin = is_flood[1]
|
| 204 |
user = q.from_user.id
|
| 205 |
user_status = (await q.message.chat.get_member(q.from_user.id)).status
|
| 206 |
if user in SUPPORT_STAFF or user_status in [CMS.OWNER, CMS.ADMINISTRATOR]:
|
| 207 |
+
if data in ["f_mute", "f_ban", "f_kick", "f_skip"]:
|
| 208 |
change = data.split("_")[1]
|
| 209 |
if not change == saction:
|
| 210 |
+
Flood.save_flood(c_id, slimit, swithin, change)
|
| 211 |
+
await q.answer("Updated action", show_alert=True)
|
| 212 |
+
await q.edit_message_text(
|
| 213 |
+
f"Set the limit of message after the flood protection will be activated\n **CURRENT LIMIT** {slimit} messages",
|
| 214 |
+
reply_markup=limit_kb
|
| 215 |
+
)
|
| 216 |
+
return
|
| 217 |
+
elif change == "skip":
|
| 218 |
+
await q.answer("Skip", show_alert=True)
|
| 219 |
+
await q.edit_message_text(
|
| 220 |
+
f"Set the limit of message after the flood protection will be activated\n **CURRENT LIMIT** {slimit} messages",
|
| 221 |
+
reply_markup=limit_kb
|
| 222 |
+
)
|
| 223 |
else:
|
| 224 |
+
await q.answer("Updated action", show_alert=True)
|
| 225 |
+
await q.edit_message_text(
|
| 226 |
+
f"Set the limit of message after the flood protection will be activated\n **CURRENT LIMIT** {slimit} messages",
|
| 227 |
+
reply_markup=limit_kb
|
| 228 |
+
)
|
| 229 |
+
elif data in ["f_5", "f_10", "f_15", "f_f_f_skip"]:
|
| 230 |
+
try:
|
| 231 |
+
change = int(data.split("_")[-1])
|
| 232 |
+
except ValueError:
|
| 233 |
+
await q.answer("skip")
|
| 234 |
+
await q.edit_message_text(
|
| 235 |
+
f"Set the time with the number of message recived treated as flood\n **CUURENT TIME** {swithin}",
|
| 236 |
+
reply_markup=within_kb
|
| 237 |
+
)
|
| 238 |
+
return
|
| 239 |
if not change == slimit:
|
| 240 |
+
Flood.save_flood(c_id, change, swithin, saction)
|
| 241 |
+
await q.answer("Updated limit", show_alert=True)
|
| 242 |
+
await q.edit_message_text(
|
| 243 |
+
f"Set the time with the number of message recived treated as flood\n **CUURENT TIME** {swithin}",
|
| 244 |
+
reply_markup=within_kb
|
| 245 |
+
)
|
| 246 |
+
return
|
| 247 |
else:
|
| 248 |
+
await q.answer("Updated action", show_alert=True)
|
| 249 |
+
await q.edit_message_text(
|
| 250 |
+
f"Set the time with the number of message recived treated as flood\n **CUURENT TIME** {swithin}",
|
| 251 |
+
reply_markup=within_kb
|
| 252 |
+
)
|
| 253 |
+
return
|
| 254 |
+
elif data in ["f_f_5", "f_f_10", "f_f_15", "f_f_skip"]:
|
| 255 |
data = data.split("_")[-1]
|
| 256 |
+
try:
|
| 257 |
+
change = int(data)
|
| 258 |
+
except ValueError:
|
| 259 |
+
await q.edit_message_text(
|
| 260 |
+
"Flood protection setting has been updated",
|
| 261 |
+
reply_markup=close_kb
|
| 262 |
+
)
|
| 263 |
+
return
|
| 264 |
+
await q.answer("skip")
|
| 265 |
if not change == swithin:
|
| 266 |
+
Flood.save_flood(c_id, slimit, change, saction)
|
| 267 |
+
await q.answer("Updated", show_alert=True)
|
| 268 |
+
await q.edit_message_text(
|
| 269 |
+
"Flood protection setting has been updated",
|
| 270 |
+
reply_markup=close_kb
|
| 271 |
+
)
|
| 272 |
+
return
|
| 273 |
else:
|
| 274 |
+
await q.answer("Updated action", show_alert=True)
|
| 275 |
+
await q.edit_message_text(
|
| 276 |
+
f"Set the limit of message after the flood protection will be activated\n **CURRENT LIMIT** {slimit} messages",
|
| 277 |
+
reply_markup=limit_kb
|
| 278 |
+
)
|
| 279 |
else:
|
| 280 |
await q.answer(
|
| 281 |
"You don't have enough permission to do this!\nStay in your limits!",
|
|
|
|
| 324 |
await q.message.edit_text(f"{q.from_user.mention} unmuted {whoo.mention}!")
|
| 325 |
return
|
| 326 |
|
| 327 |
+
dic = {}
|
| 328 |
@Gojo.on_message(filters.all & ~filters.bot | ~filters.private, 10)
|
| 329 |
async def flood_watcher(c: Gojo, m: Message):
|
| 330 |
c_id = m.chat.id
|
| 331 |
+
Flood = Floods()
|
| 332 |
u_id = m.from_user.id
|
| 333 |
is_flood = Flood.is_chat(c_id)
|
| 334 |
+
if not is_flood:
|
| 335 |
+
return # return of chat is not in anti flood protection
|
| 336 |
app_users = Approve(m.chat.id).list_approved()
|
| 337 |
if u_id in {i[0] for i in app_users}:
|
| 338 |
return #return if the user is approved
|
|
|
|
| 344 |
action = is_flood[2]
|
| 345 |
limit = int(is_flood[0])
|
| 346 |
within = int(is_flood[1])
|
| 347 |
+
if not len(dic):
|
| 348 |
+
z = {c_id : {u_id : [[],[]]}}
|
| 349 |
+
dic.update(z)
|
| 350 |
+
for i in dic.keys():
|
| 351 |
+
if c_id != i:
|
| 352 |
+
z = {c_id : {u_id : [[],[]]}}
|
| 353 |
dic.update(z)
|
| 354 |
+
|
| 355 |
+
for i in dic[c_id].keys():
|
| 356 |
+
if u_id != i:
|
| 357 |
z = {u_id : [[],[]]}
|
| 358 |
+
dic[c_id].update(z) # make the dic something like {c_id : {u_id : [[for time],[for msg]]}}
|
| 359 |
sec = round(time.time())
|
| 360 |
try:
|
| 361 |
dic[c_id][u_id][0].append(sec)
|
| 362 |
dic[c_id][u_id][1].append("x")
|
| 363 |
except KeyError:
|
| 364 |
+
dic[c_id].update({u_id : [[sec], ["x"]]})
|
| 365 |
+
x = int(dic[c_id][u_id][0][0])
|
| 366 |
+
y = int(dic[c_id][u_id][0][-1])
|
| 367 |
+
if len(dic[c_id][u_id][1]) == limit:
|
| 368 |
if y-x <= within:
|
| 369 |
if action == "ban":
|
| 370 |
try:
|
Powers/plugins/utils.py
CHANGED
|
@@ -16,8 +16,8 @@ from Powers.bot_class import Gojo
|
|
| 16 |
from Powers.database.users_db import Users
|
| 17 |
from Powers.utils.clean_file import remove_markdown_and_html
|
| 18 |
from Powers.utils.custom_filters import command
|
| 19 |
-
from Powers.utils.http_helper import *
|
| 20 |
from Powers.utils.extract_user import extract_user
|
|
|
|
| 21 |
from Powers.utils.parser import mention_html
|
| 22 |
|
| 23 |
|
|
|
|
| 16 |
from Powers.database.users_db import Users
|
| 17 |
from Powers.utils.clean_file import remove_markdown_and_html
|
| 18 |
from Powers.utils.custom_filters import command
|
|
|
|
| 19 |
from Powers.utils.extract_user import extract_user
|
| 20 |
+
from Powers.utils.http_helper import *
|
| 21 |
from Powers.utils.parser import mention_html
|
| 22 |
|
| 23 |
|