CliRemote 1.7.8__py3-none-any.whl → 1.7.10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cliremote-1.7.8.dist-info → cliremote-1.7.10.dist-info}/METADATA +1 -1
- {cliremote-1.7.8.dist-info → cliremote-1.7.10.dist-info}/RECORD +6 -6
- remote/admin_manager.py +58 -44
- {cliremote-1.7.8.dist-info → cliremote-1.7.10.dist-info}/WHEEL +0 -0
- {cliremote-1.7.8.dist-info → cliremote-1.7.10.dist-info}/licenses/LICENSE +0 -0
- {cliremote-1.7.8.dist-info → cliremote-1.7.10.dist-info}/top_level.txt +0 -0
@@ -1,8 +1,8 @@
|
|
1
|
-
cliremote-1.7.
|
1
|
+
cliremote-1.7.10.dist-info/licenses/LICENSE,sha256=O-0zMbcEi6wXz1DiSdVgzMlQjJcNqNe5KDv08uYzqR0,1055
|
2
2
|
remote/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
3
|
remote/account_manager.py,sha256=TepnGIoE2hU-j_NmU5ByoS-JrboE0w3A1bYmQoQX5h8,15176
|
4
4
|
remote/account_viewer.py,sha256=j46KSjbgrBmBi7UxFeJ5tCwHIe0QvCvphkirGIbB2oo,5192
|
5
|
-
remote/admin_manager.py,sha256=
|
5
|
+
remote/admin_manager.py,sha256=lgpdN3Mo6YzxNNm7eb7fjGuKzzkV39VRGafpavrAp8Y,4802
|
6
6
|
remote/analytics_manager.py,sha256=6jPvwt_ELA4RMbQdD8W_ltfAoaSgILnEkOAp6HZAqsU,7382
|
7
7
|
remote/batch_manager.py,sha256=jVGhYVwHMKJd7f7JxcWjKlwr03dq0RaGD1KdkyYdb00,1051
|
8
8
|
remote/block_manager.py,sha256=R7UaQigr-hTRtjxjG3OvJdKhvp0mDpLaESp3Of1AYhs,5692
|
@@ -33,7 +33,7 @@ remote/text_manager.py,sha256=C2wNSXPSCDu8NSD3RsfbKmUQMWOYd1B5N4tzy-Jsriw,2195
|
|
33
33
|
remote/username_manager.py,sha256=nMNdke-2FIv86xR1Y6rR-43oUoQu_3Khw8wEo54noXI,3388
|
34
34
|
remote/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
35
35
|
remote/utils/sqlite_utils.py,sha256=5i0oUXsBgKC_8qHZPJ-Gyhp9D1TwqKHVvuZRIhKpS6w,1260
|
36
|
-
cliremote-1.7.
|
37
|
-
cliremote-1.7.
|
38
|
-
cliremote-1.7.
|
39
|
-
cliremote-1.7.
|
36
|
+
cliremote-1.7.10.dist-info/METADATA,sha256=QTB61ZPptktRQaQTzGvRU5-F5vX4JatOmWdT_STGw1Y,1203
|
37
|
+
cliremote-1.7.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
38
|
+
cliremote-1.7.10.dist-info/top_level.txt,sha256=yBZidJ6zCix_a2ubGlYaewvlzBFXWbckQt20dudxJ1E,7
|
39
|
+
cliremote-1.7.10.dist-info/RECORD,,
|
remote/admin_manager.py
CHANGED
@@ -1,67 +1,80 @@
|
|
1
1
|
# remote/admin_manager.py
|
2
|
-
import json, os, logging
|
2
|
+
import json, os, sys, logging
|
3
|
+
from pathlib import Path
|
3
4
|
from pyrogram import filters
|
4
5
|
from .config import OWNER_ID
|
5
6
|
|
6
7
|
logger = logging.getLogger(__name__)
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
def load_admins() -> list[int]:
|
9
|
+
def _project_root() -> Path:
|
12
10
|
"""
|
13
|
-
|
14
|
-
همیشه OWNER_ID را هم به لیست اضافه میکند.
|
11
|
+
ریشه پروژه = پوشهای که main.py داخلش اجرا شده.
|
15
12
|
"""
|
16
|
-
s = set(OWNER_ID)
|
17
13
|
try:
|
18
|
-
|
19
|
-
|
14
|
+
main_file = Path(sys.modules["__main__"].__file__).resolve()
|
15
|
+
return main_file.parent
|
16
|
+
except Exception:
|
17
|
+
# fallback: اگر به هر دلیل __main__.__file__ نبود
|
18
|
+
return Path(os.getcwd()).resolve()
|
19
|
+
|
20
|
+
PROJECT_ROOT = _project_root()
|
21
|
+
ADMINS_FILE = PROJECT_ROOT / "admins.json" # ✅ کنار main.py
|
22
|
+
|
23
|
+
def _load_admins_from_file() -> list[int]:
|
24
|
+
try:
|
25
|
+
if ADMINS_FILE.exists():
|
26
|
+
with ADMINS_FILE.open("r", encoding="utf-8") as f:
|
20
27
|
data = json.load(f)
|
21
28
|
if isinstance(data, list):
|
29
|
+
out = []
|
22
30
|
for v in data:
|
23
31
|
try:
|
24
|
-
|
25
|
-
except:
|
26
|
-
|
32
|
+
out.append(int(v))
|
33
|
+
except Exception:
|
34
|
+
logger.warning(f"Bad admin id in file: {v!r}")
|
35
|
+
return out
|
27
36
|
except Exception as e:
|
28
|
-
logger.warning(f"Error loading admins: {e}")
|
29
|
-
return
|
37
|
+
logger.warning(f"Error loading admins from {ADMINS_FILE}: {e}")
|
38
|
+
return []
|
39
|
+
|
40
|
+
# لیست ادمینهای موثر (فایل + Owner)
|
41
|
+
ADMINS: list[int] = []
|
30
42
|
|
43
|
+
def reload_admins():
|
44
|
+
"""فایل را میخواند و با OWNER_ID ادغام میکند؛ نتیجه در ADMINS."""
|
45
|
+
file_admins = _load_admins_from_file()
|
46
|
+
s = set(file_admins) | set(OWNER_ID)
|
47
|
+
global ADMINS
|
48
|
+
ADMINS = sorted(s)
|
49
|
+
logger.info(f"Loaded admins ({ADMINS_FILE}): {ADMINS}")
|
31
50
|
|
32
51
|
def save_admins():
|
33
52
|
"""
|
34
|
-
|
53
|
+
ذخیره در فایل کنار main.py.
|
54
|
+
فقط ادمینهای غیر-Owner را داخل فایل نگه میداریم (Ownerها از config میآیند).
|
35
55
|
"""
|
36
56
|
try:
|
37
|
-
|
38
|
-
|
57
|
+
file_list = [x for x in ADMINS if x not in set(OWNER_ID)]
|
58
|
+
with ADMINS_FILE.open("w", encoding="utf-8") as f:
|
59
|
+
json.dump(file_list, f, ensure_ascii=False, indent=2)
|
60
|
+
logger.info(f"Saved admins to {ADMINS_FILE}: {file_list}")
|
39
61
|
except Exception as e:
|
40
62
|
logger.error(f"Error saving admins: {e}")
|
41
63
|
|
42
|
-
|
43
|
-
ADMINS = load_admins()
|
44
|
-
|
45
|
-
# فیلترهای دسترسی برای Pyrogram
|
64
|
+
# فیلترهای دسترسی
|
46
65
|
admin_filter = filters.create(
|
47
|
-
lambda _, __, m: bool(getattr(m, "from_user", None))
|
48
|
-
and int(m.from_user.id) in ADMINS
|
66
|
+
lambda _, __, m: bool(getattr(m, "from_user", None)) and int(m.from_user.id) in ADMINS
|
49
67
|
)
|
50
68
|
owner_filter = filters.create(
|
51
|
-
lambda _, __, m: bool(getattr(m, "from_user", None))
|
52
|
-
and int(m.from_user.id) in OWNER_ID
|
69
|
+
lambda _, __, m: bool(getattr(m, "from_user", None)) and int(m.from_user.id) in OWNER_ID
|
53
70
|
)
|
54
71
|
|
55
|
-
|
56
|
-
# =============================
|
57
|
-
# فرمانهای مدیریتی
|
58
|
-
# =============================
|
59
|
-
|
72
|
+
# ===== فرمانها =====
|
60
73
|
async def add_admin_cmd(message):
|
61
74
|
try:
|
62
|
-
parts = message.text.split()
|
75
|
+
parts = (message.text or "").split()
|
63
76
|
if len(parts) < 2:
|
64
|
-
await message.reply("مثال: addadmin 123456789")
|
77
|
+
await message.reply("مثال: /addadmin 123456789")
|
65
78
|
return
|
66
79
|
uid = int(parts[1])
|
67
80
|
if uid in OWNER_ID:
|
@@ -69,20 +82,21 @@ async def add_admin_cmd(message):
|
|
69
82
|
return
|
70
83
|
if uid not in ADMINS:
|
71
84
|
ADMINS.append(uid)
|
85
|
+
ADMINS[:] = sorted(set(ADMINS) | set(OWNER_ID))
|
72
86
|
save_admins()
|
73
|
-
await message.reply(f"ادمین جدید اضافه شد: {uid}")
|
87
|
+
await message.reply(f"ادمین جدید اضافه شد: <code>{uid}</code>")
|
88
|
+
logger.info(f"Admin added: {uid}")
|
74
89
|
else:
|
75
90
|
await message.reply("قبلاً ادمین بود")
|
76
91
|
except Exception as e:
|
77
|
-
logger.error(f"add_admin_cmd error: {e}")
|
92
|
+
logger.error(f"add_admin_cmd error: {e}", exc_info=True)
|
78
93
|
await message.reply(f"خطا: {e}")
|
79
94
|
|
80
|
-
|
81
95
|
async def del_admin_cmd(message):
|
82
96
|
try:
|
83
|
-
parts = message.text.split()
|
97
|
+
parts = (message.text or "").split()
|
84
98
|
if len(parts) < 2:
|
85
|
-
await message.reply("مثال: deladmin 123456789")
|
99
|
+
await message.reply("مثال: /deladmin 123456789")
|
86
100
|
return
|
87
101
|
uid = int(parts[1])
|
88
102
|
if uid in OWNER_ID:
|
@@ -91,21 +105,21 @@ async def del_admin_cmd(message):
|
|
91
105
|
if uid in ADMINS:
|
92
106
|
ADMINS.remove(uid)
|
93
107
|
save_admins()
|
94
|
-
await message.reply(f"ادمین حذف شد: {uid}")
|
108
|
+
await message.reply(f"ادمین حذف شد: <code>{uid}</code>")
|
109
|
+
logger.info(f"Admin removed: {uid}")
|
95
110
|
else:
|
96
111
|
await message.reply("کاربر ادمین نیست")
|
97
112
|
except Exception as e:
|
98
|
-
logger.error(f"del_admin_cmd error: {e}")
|
113
|
+
logger.error(f"del_admin_cmd error: {e}", exc_info=True)
|
99
114
|
await message.reply(f"خطا: {e}")
|
100
115
|
|
101
|
-
|
102
116
|
async def list_admins_cmd(message):
|
103
117
|
try:
|
104
118
|
if not ADMINS:
|
105
119
|
await message.reply("لیست ادمینها خالی است.")
|
106
120
|
return
|
107
|
-
text = "👑 <b>ADMINS:</b>\n" + "\n".join([
|
108
|
-
await message.reply(text)
|
121
|
+
text = "👑 <b>ADMINS:</b>\n" + "\n".join([f"<code>{x}</code>" for x in ADMINS])
|
122
|
+
await message.reply(text, disable_web_page_preview=True)
|
109
123
|
except Exception as e:
|
110
|
-
logger.error(f"list_admins_cmd error: {e}")
|
124
|
+
logger.error(f"list_admins_cmd error: {e}", exc_info=True)
|
111
125
|
await message.reply(f"خطا: {e}")
|
File without changes
|
File without changes
|
File without changes
|