Spaces:
Paused
Paused
Captain Ezio
commited on
Commit
·
ebf51e7
1
Parent(s):
c06465a
Looks great
Browse files- Powers/database/flood_db.py +15 -13
- Powers/plugins/flood.py +6 -8
- Powers/utils/extras.py +26 -0
Powers/database/flood_db.py
CHANGED
|
@@ -9,11 +9,10 @@ INSERTION_LOCK = RLock()
|
|
| 9 |
|
| 10 |
class Floods(MongoDB):
|
| 11 |
"""Class to store flood limit and action of a chat"""
|
| 12 |
-
|
| 13 |
-
db_name = "flood"
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
|
| 18 |
def save_flood(
|
| 19 |
self,
|
|
@@ -23,7 +22,7 @@ class Floods(MongoDB):
|
|
| 23 |
action: str,
|
| 24 |
):
|
| 25 |
with INSERTION_LOCK:
|
| 26 |
-
curr = self.find_one({"chat_id": chat_id
|
| 27 |
if curr:
|
| 28 |
if not(limit == int(curr['limit']) or within == int(curr['within']) or action == str(curr['action'])):
|
| 29 |
return self.update(
|
|
@@ -34,14 +33,17 @@ class Floods(MongoDB):
|
|
| 34 |
"action": action,
|
| 35 |
}
|
| 36 |
)
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
def is_chat(self, chat_id: int):
|
| 47 |
with INSERTION_LOCK:
|
|
|
|
| 9 |
|
| 10 |
class Floods(MongoDB):
|
| 11 |
"""Class to store flood limit and action of a chat"""
|
| 12 |
+
db_name = "flood"
|
|
|
|
| 13 |
|
| 14 |
+
def __init__(self):
|
| 15 |
+
super().__init__(self.db_name)
|
| 16 |
|
| 17 |
def save_flood(
|
| 18 |
self,
|
|
|
|
| 22 |
action: str,
|
| 23 |
):
|
| 24 |
with INSERTION_LOCK:
|
| 25 |
+
curr = self.find_one({"chat_id": chat_id})
|
| 26 |
if curr:
|
| 27 |
if not(limit == int(curr['limit']) or within == int(curr['within']) or action == str(curr['action'])):
|
| 28 |
return self.update(
|
|
|
|
| 33 |
"action": action,
|
| 34 |
}
|
| 35 |
)
|
| 36 |
+
else:
|
| 37 |
+
return
|
| 38 |
+
else:
|
| 39 |
+
return self.insert_one(
|
| 40 |
+
{
|
| 41 |
+
"chat_id" : chat_id,
|
| 42 |
+
"limit": limit,
|
| 43 |
+
"within": within,
|
| 44 |
+
"action" : action
|
| 45 |
+
},
|
| 46 |
+
)
|
| 47 |
|
| 48 |
def is_chat(self, chat_id: int):
|
| 49 |
with INSERTION_LOCK:
|
Powers/plugins/flood.py
CHANGED
|
@@ -142,22 +142,20 @@ 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 |
if len(split) == 1:
|
| 146 |
c_id = m.chat.id
|
| 147 |
-
if is_flood:
|
| 148 |
-
saction = is_flood[2]
|
| 149 |
-
slimit = is_flood[0]
|
| 150 |
-
swithin = is_flood[1]
|
| 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 |
|
| 154 |
if len(split) == 2:
|
| 155 |
-
if is_flood:
|
| 156 |
-
saction = is_flood[2]
|
| 157 |
-
slimit = is_flood[0]
|
| 158 |
-
swithin = is_flood[1]
|
| 159 |
c_id = m.chat.id
|
| 160 |
if split[1].lower() in on_key:
|
|
|
|
|
|
|
| 161 |
Flood.save_flood(m.chat.id, 5, 5, 'mute')
|
| 162 |
await m.reply_text("Flood protection has been started for this group.")
|
| 163 |
return
|
|
|
|
| 142 |
split = m.text.split(None, 1)
|
| 143 |
c_id = m.chat.id
|
| 144 |
is_flood = Flood.is_chat(c_id)
|
| 145 |
+
saction = is_flood[2]
|
| 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 |
|
| 154 |
if len(split) == 2:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
c_id = m.chat.id
|
| 156 |
if split[1].lower() in on_key:
|
| 157 |
+
if is_flood:
|
| 158 |
+
return await m.reply_text(f"Flood is on for this chat\n**Action**:{saction}\n**Messages**:{slimit} within {swithin} sec")
|
| 159 |
Flood.save_flood(m.chat.id, 5, 5, 'mute')
|
| 160 |
await m.reply_text("Flood protection has been started for this group.")
|
| 161 |
return
|
Powers/utils/extras.py
CHANGED
|
@@ -663,4 +663,30 @@ StartPic = [
|
|
| 663 |
"https://te.legra.ph/file/1751252a9f0483811e9b9.jpg",
|
| 664 |
"https://te.legra.ph/file/380b862e0248225cc1a45.jpg",
|
| 665 |
"https://te.legra.ph/file/f314f89640ce4b4118e9e.jpg",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 666 |
]
|
|
|
|
| 663 |
"https://te.legra.ph/file/1751252a9f0483811e9b9.jpg",
|
| 664 |
"https://te.legra.ph/file/380b862e0248225cc1a45.jpg",
|
| 665 |
"https://te.legra.ph/file/f314f89640ce4b4118e9e.jpg",
|
| 666 |
+
"https://te.legra.ph/file/37423e9680e3f79c9eb15.jpg",
|
| 667 |
+
"https://te.legra.ph/file/4a9c4663d0120cff7cc82.jpg",
|
| 668 |
+
"https://te.legra.ph/file/56d72d125005a16dba7b8.jpg",
|
| 669 |
+
"https://te.legra.ph/file/c10f1b32adaf93c1a9fe1.jpg",
|
| 670 |
+
"https://te.legra.ph/file/68c607517cca7d08e8910.jpg",
|
| 671 |
+
"https://te.legra.ph/file/c86855e6d5a5668748ce1.jpg",
|
| 672 |
+
"https://te.legra.ph/file/b480c0989f1e4a9ea63c7.jpg",
|
| 673 |
+
"https://te.legra.ph/file/4cdf315e2925d8b4ef6ae.jpg",
|
| 674 |
+
"https://te.legra.ph/file/fe9c620d294f4f47f4350.jpg",
|
| 675 |
+
"https://te.legra.ph/file/6d4ae604c118cb49ab7ed.jpg",
|
| 676 |
+
"https://te.legra.ph/file/a7a78ff8d710583f28e72.jpg",
|
| 677 |
+
"https://te.legra.ph/file/a7a78ff8d710583f28e72.jpg",
|
| 678 |
+
"https://te.legra.ph/file/c74c4f4be365971311510.jpg",
|
| 679 |
+
"https://te.legra.ph/file/23e0a389fb5df7900c686.jpg",
|
| 680 |
+
"https://te.legra.ph/file/fc0557000a350267adc0d.jpg",
|
| 681 |
+
"https://te.legra.ph/file/cd381fd6f9960555664f6.jpg",
|
| 682 |
+
"https://te.legra.ph/file/322466833973279848e60.jpg",
|
| 683 |
+
"https://te.legra.ph/file/122cf568eef282ad3472a.jpg",
|
| 684 |
+
"https://te.legra.ph/file/cd6aa9cbe621c7c3a12ea.jpg",
|
| 685 |
+
"https://te.legra.ph/file/83c61271b95fdf421a9a0.jpg",
|
| 686 |
+
"https://te.legra.ph/file/2f27c940f5e912c01aa63.jpg",
|
| 687 |
+
"https://te.legra.ph/file/43780c4a5c3071af3de3c.jpg",
|
| 688 |
+
"https://te.legra.ph/file/68d18ae5b2a4b67e793a4.jpg",
|
| 689 |
+
"https://te.legra.ph/file/633bd27c1607fe98920b6.jpg",
|
| 690 |
+
"https://te.legra.ph/file/52d92a67f0c6ce0a9f89f.jpg",
|
| 691 |
+
"https://te.legra.ph/file/d91e7353b3803a8148bfc.jpg",
|
| 692 |
]
|