Spaces:
Paused
Paused
Captain Ezio
commited on
Commit
·
9b9f5b9
1
Parent(s):
3dbb2e0
....
Browse files- Powers/plugins/clean_db.py +6 -34
Powers/plugins/clean_db.py
CHANGED
|
@@ -18,7 +18,7 @@ from Powers.database.greetings_db import Greetings
|
|
| 18 |
from Powers.database.notes_db import Notes, NotesSettings
|
| 19 |
from Powers.database.pins_db import Pins
|
| 20 |
from Powers.database.reporting_db import Reporting
|
| 21 |
-
from Powers.database.users_db import Users
|
| 22 |
from Powers.database.warns_db import Warns, WarnSettings
|
| 23 |
from Powers.utils.custom_filters import command
|
| 24 |
from Powers.vars import Config
|
|
@@ -26,7 +26,6 @@ from Powers.vars import Config
|
|
| 26 |
|
| 27 |
async def clean_my_db(c:Gojo,is_cmd=False, id=None):
|
| 28 |
to_clean = list()
|
| 29 |
-
all_userss = Users.list_users()
|
| 30 |
chats_list = Chats.list_chats_by_id()
|
| 31 |
to_clean.clear()
|
| 32 |
start = time.time()
|
|
@@ -40,7 +39,10 @@ async def clean_my_db(c:Gojo,is_cmd=False, id=None):
|
|
| 40 |
except Exception as e:
|
| 41 |
LOGGER.error(e)
|
| 42 |
LOGGER.error(format_exc())
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
| 44 |
for i in to_clean:
|
| 45 |
Approve(i).clean_approve()
|
| 46 |
Blacklist(i).clean_blacklist()
|
|
@@ -58,37 +60,7 @@ async def clean_my_db(c:Gojo,is_cmd=False, id=None):
|
|
| 58 |
x = len(to_clean)
|
| 59 |
txt = f"#INFO\n\nCleaned db:\nTotal chats removed: {x}"
|
| 60 |
to_clean.clear()
|
| 61 |
-
|
| 62 |
-
await sleep(60)
|
| 63 |
-
LOGGER.info("Continuing the cleaning process")
|
| 64 |
-
all_users = [i["_id"] for i in all_userss]
|
| 65 |
-
for i in all_users:
|
| 66 |
-
try:
|
| 67 |
-
infos = await c.get_users(int(i))
|
| 68 |
-
except PeerIdInvalid:
|
| 69 |
-
try:
|
| 70 |
-
inn = await c.resolve_peer(int(i))
|
| 71 |
-
infos = await c.get_users(inn.user_id)
|
| 72 |
-
except KeyError:
|
| 73 |
-
to_clean.append(i)
|
| 74 |
-
Users(i).delete_user()
|
| 75 |
-
except Exception as e:
|
| 76 |
-
LOGGER.error(e)
|
| 77 |
-
LOGGER.error(format_exc())
|
| 78 |
-
return e
|
| 79 |
-
except Exception as e:
|
| 80 |
-
LOGGER.error(e)
|
| 81 |
-
LOGGER.error(format_exc())
|
| 82 |
-
return e
|
| 83 |
-
try:
|
| 84 |
-
if infos.is_deleted:
|
| 85 |
-
to_clean.append(infos.id)
|
| 86 |
-
Users(infos.id).delete_user()
|
| 87 |
-
else:
|
| 88 |
-
pass
|
| 89 |
-
except Exception:
|
| 90 |
-
pass
|
| 91 |
-
|
| 92 |
txt += f"\nTotal users removed: {len(to_clean)}"
|
| 93 |
to_clean.clear()
|
| 94 |
if is_cmd:
|
|
|
|
| 18 |
from Powers.database.notes_db import Notes, NotesSettings
|
| 19 |
from Powers.database.pins_db import Pins
|
| 20 |
from Powers.database.reporting_db import Reporting
|
| 21 |
+
# from Powers.database.users_db import Users
|
| 22 |
from Powers.database.warns_db import Warns, WarnSettings
|
| 23 |
from Powers.utils.custom_filters import command
|
| 24 |
from Powers.vars import Config
|
|
|
|
| 26 |
|
| 27 |
async def clean_my_db(c:Gojo,is_cmd=False, id=None):
|
| 28 |
to_clean = list()
|
|
|
|
| 29 |
chats_list = Chats.list_chats_by_id()
|
| 30 |
to_clean.clear()
|
| 31 |
start = time.time()
|
|
|
|
| 39 |
except Exception as e:
|
| 40 |
LOGGER.error(e)
|
| 41 |
LOGGER.error(format_exc())
|
| 42 |
+
if not is_cmd:
|
| 43 |
+
return e
|
| 44 |
+
else:
|
| 45 |
+
to_clean.append()
|
| 46 |
for i in to_clean:
|
| 47 |
Approve(i).clean_approve()
|
| 48 |
Blacklist(i).clean_blacklist()
|
|
|
|
| 60 |
x = len(to_clean)
|
| 61 |
txt = f"#INFO\n\nCleaned db:\nTotal chats removed: {x}"
|
| 62 |
to_clean.clear()
|
| 63 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
txt += f"\nTotal users removed: {len(to_clean)}"
|
| 65 |
to_clean.clear()
|
| 66 |
if is_cmd:
|