CliRemote 1.7.8__tar.gz → 1.7.10__tar.gz
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 → cliremote-1.7.10}/CliRemote.egg-info/PKG-INFO +1 -1
- {cliremote-1.7.8 → cliremote-1.7.10}/PKG-INFO +1 -1
- {cliremote-1.7.8 → cliremote-1.7.10}/pyproject.toml +1 -1
- cliremote-1.7.10/remote/admin_manager.py +125 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/setup.py +1 -1
- cliremote-1.7.8/remote/admin_manager.py +0 -111
- {cliremote-1.7.8 → cliremote-1.7.10}/CliRemote.egg-info/SOURCES.txt +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/CliRemote.egg-info/dependency_links.txt +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/CliRemote.egg-info/requires.txt +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/CliRemote.egg-info/top_level.txt +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/LICENSE +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/MANIFEST.in +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/README.md +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/__init__.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/account_manager.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/account_viewer.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/analytics_manager.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/batch_manager.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/block_manager.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/caption_manager.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/cleaner.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/client_manager.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/client_picker.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/config.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/device_manager.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/file_sender.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/getcode_controller.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/health.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/help_menu.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/init.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/join_controller.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/joiner.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/leave_controller.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/lefter.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/mention_manager.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/precise_engine.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/profile_info.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/profile_media.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/profile_privacy.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/spammer.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/speed_manager.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/stop_manager.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/text_manager.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/username_manager.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/utils/__init__.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/remote/utils/sqlite_utils.py +0 -0
- {cliremote-1.7.8 → cliremote-1.7.10}/setup.cfg +0 -0
@@ -0,0 +1,125 @@
|
|
1
|
+
# remote/admin_manager.py
|
2
|
+
import json, os, sys, logging
|
3
|
+
from pathlib import Path
|
4
|
+
from pyrogram import filters
|
5
|
+
from .config import OWNER_ID
|
6
|
+
|
7
|
+
logger = logging.getLogger(__name__)
|
8
|
+
|
9
|
+
def _project_root() -> Path:
|
10
|
+
"""
|
11
|
+
ریشه پروژه = پوشهای که main.py داخلش اجرا شده.
|
12
|
+
"""
|
13
|
+
try:
|
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:
|
27
|
+
data = json.load(f)
|
28
|
+
if isinstance(data, list):
|
29
|
+
out = []
|
30
|
+
for v in data:
|
31
|
+
try:
|
32
|
+
out.append(int(v))
|
33
|
+
except Exception:
|
34
|
+
logger.warning(f"Bad admin id in file: {v!r}")
|
35
|
+
return out
|
36
|
+
except Exception as e:
|
37
|
+
logger.warning(f"Error loading admins from {ADMINS_FILE}: {e}")
|
38
|
+
return []
|
39
|
+
|
40
|
+
# لیست ادمینهای موثر (فایل + Owner)
|
41
|
+
ADMINS: list[int] = []
|
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}")
|
50
|
+
|
51
|
+
def save_admins():
|
52
|
+
"""
|
53
|
+
ذخیره در فایل کنار main.py.
|
54
|
+
فقط ادمینهای غیر-Owner را داخل فایل نگه میداریم (Ownerها از config میآیند).
|
55
|
+
"""
|
56
|
+
try:
|
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}")
|
61
|
+
except Exception as e:
|
62
|
+
logger.error(f"Error saving admins: {e}")
|
63
|
+
|
64
|
+
# فیلترهای دسترسی
|
65
|
+
admin_filter = filters.create(
|
66
|
+
lambda _, __, m: bool(getattr(m, "from_user", None)) and int(m.from_user.id) in ADMINS
|
67
|
+
)
|
68
|
+
owner_filter = filters.create(
|
69
|
+
lambda _, __, m: bool(getattr(m, "from_user", None)) and int(m.from_user.id) in OWNER_ID
|
70
|
+
)
|
71
|
+
|
72
|
+
# ===== فرمانها =====
|
73
|
+
async def add_admin_cmd(message):
|
74
|
+
try:
|
75
|
+
parts = (message.text or "").split()
|
76
|
+
if len(parts) < 2:
|
77
|
+
await message.reply("مثال: /addadmin 123456789")
|
78
|
+
return
|
79
|
+
uid = int(parts[1])
|
80
|
+
if uid in OWNER_ID:
|
81
|
+
await message.reply("ادمین اصلی از قبل وجود دارد")
|
82
|
+
return
|
83
|
+
if uid not in ADMINS:
|
84
|
+
ADMINS.append(uid)
|
85
|
+
ADMINS[:] = sorted(set(ADMINS) | set(OWNER_ID))
|
86
|
+
save_admins()
|
87
|
+
await message.reply(f"ادمین جدید اضافه شد: <code>{uid}</code>")
|
88
|
+
logger.info(f"Admin added: {uid}")
|
89
|
+
else:
|
90
|
+
await message.reply("قبلاً ادمین بود")
|
91
|
+
except Exception as e:
|
92
|
+
logger.error(f"add_admin_cmd error: {e}", exc_info=True)
|
93
|
+
await message.reply(f"خطا: {e}")
|
94
|
+
|
95
|
+
async def del_admin_cmd(message):
|
96
|
+
try:
|
97
|
+
parts = (message.text or "").split()
|
98
|
+
if len(parts) < 2:
|
99
|
+
await message.reply("مثال: /deladmin 123456789")
|
100
|
+
return
|
101
|
+
uid = int(parts[1])
|
102
|
+
if uid in OWNER_ID:
|
103
|
+
await message.reply("❌ امکان حذف ادمین اصلی وجود ندارد")
|
104
|
+
return
|
105
|
+
if uid in ADMINS:
|
106
|
+
ADMINS.remove(uid)
|
107
|
+
save_admins()
|
108
|
+
await message.reply(f"ادمین حذف شد: <code>{uid}</code>")
|
109
|
+
logger.info(f"Admin removed: {uid}")
|
110
|
+
else:
|
111
|
+
await message.reply("کاربر ادمین نیست")
|
112
|
+
except Exception as e:
|
113
|
+
logger.error(f"del_admin_cmd error: {e}", exc_info=True)
|
114
|
+
await message.reply(f"خطا: {e}")
|
115
|
+
|
116
|
+
async def list_admins_cmd(message):
|
117
|
+
try:
|
118
|
+
if not ADMINS:
|
119
|
+
await message.reply("لیست ادمینها خالی است.")
|
120
|
+
return
|
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)
|
123
|
+
except Exception as e:
|
124
|
+
logger.error(f"list_admins_cmd error: {e}", exc_info=True)
|
125
|
+
await message.reply(f"خطا: {e}")
|
@@ -5,7 +5,7 @@ with open("README.md", encoding="utf-8") as f:
|
|
5
5
|
|
6
6
|
setup(
|
7
7
|
name="CliRemote",
|
8
|
-
version="1.7.
|
8
|
+
version="1.7.10",
|
9
9
|
author="MrAhmadiRad",
|
10
10
|
author_email="mohammadahmadirad69@gmail.com",
|
11
11
|
description="A precise, async-safe, Telegram automation core (Python 3.8+)",
|
@@ -1,111 +0,0 @@
|
|
1
|
-
# remote/admin_manager.py
|
2
|
-
import json, os, logging
|
3
|
-
from pyrogram import filters
|
4
|
-
from .config import OWNER_ID
|
5
|
-
|
6
|
-
logger = logging.getLogger(__name__)
|
7
|
-
|
8
|
-
ADMINS_FILE = "admins.json"
|
9
|
-
|
10
|
-
|
11
|
-
def load_admins() -> list[int]:
|
12
|
-
"""
|
13
|
-
بارگذاری لیست ادمینها از فایل.
|
14
|
-
همیشه OWNER_ID را هم به لیست اضافه میکند.
|
15
|
-
"""
|
16
|
-
s = set(OWNER_ID)
|
17
|
-
try:
|
18
|
-
if os.path.exists(ADMINS_FILE):
|
19
|
-
with open(ADMINS_FILE, "r", encoding="utf-8") as f:
|
20
|
-
data = json.load(f)
|
21
|
-
if isinstance(data, list):
|
22
|
-
for v in data:
|
23
|
-
try:
|
24
|
-
s.add(int(v))
|
25
|
-
except:
|
26
|
-
pass
|
27
|
-
except Exception as e:
|
28
|
-
logger.warning(f"Error loading admins: {e}")
|
29
|
-
return list(s)
|
30
|
-
|
31
|
-
|
32
|
-
def save_admins():
|
33
|
-
"""
|
34
|
-
ذخیرهی ادمینها در فایل.
|
35
|
-
"""
|
36
|
-
try:
|
37
|
-
with open(ADMINS_FILE, "w", encoding="utf-8") as f:
|
38
|
-
json.dump(list(ADMINS), f, ensure_ascii=False, indent=2)
|
39
|
-
except Exception as e:
|
40
|
-
logger.error(f"Error saving admins: {e}")
|
41
|
-
|
42
|
-
|
43
|
-
ADMINS = load_admins()
|
44
|
-
|
45
|
-
# فیلترهای دسترسی برای Pyrogram
|
46
|
-
admin_filter = filters.create(
|
47
|
-
lambda _, __, m: bool(getattr(m, "from_user", None))
|
48
|
-
and int(m.from_user.id) in ADMINS
|
49
|
-
)
|
50
|
-
owner_filter = filters.create(
|
51
|
-
lambda _, __, m: bool(getattr(m, "from_user", None))
|
52
|
-
and int(m.from_user.id) in OWNER_ID
|
53
|
-
)
|
54
|
-
|
55
|
-
|
56
|
-
# =============================
|
57
|
-
# فرمانهای مدیریتی
|
58
|
-
# =============================
|
59
|
-
|
60
|
-
async def add_admin_cmd(message):
|
61
|
-
try:
|
62
|
-
parts = message.text.split()
|
63
|
-
if len(parts) < 2:
|
64
|
-
await message.reply("مثال: addadmin 123456789")
|
65
|
-
return
|
66
|
-
uid = int(parts[1])
|
67
|
-
if uid in OWNER_ID:
|
68
|
-
await message.reply("ادمین اصلی از قبل وجود دارد")
|
69
|
-
return
|
70
|
-
if uid not in ADMINS:
|
71
|
-
ADMINS.append(uid)
|
72
|
-
save_admins()
|
73
|
-
await message.reply(f"ادمین جدید اضافه شد: {uid}")
|
74
|
-
else:
|
75
|
-
await message.reply("قبلاً ادمین بود")
|
76
|
-
except Exception as e:
|
77
|
-
logger.error(f"add_admin_cmd error: {e}")
|
78
|
-
await message.reply(f"خطا: {e}")
|
79
|
-
|
80
|
-
|
81
|
-
async def del_admin_cmd(message):
|
82
|
-
try:
|
83
|
-
parts = message.text.split()
|
84
|
-
if len(parts) < 2:
|
85
|
-
await message.reply("مثال: deladmin 123456789")
|
86
|
-
return
|
87
|
-
uid = int(parts[1])
|
88
|
-
if uid in OWNER_ID:
|
89
|
-
await message.reply("❌ امکان حذف ادمین اصلی وجود ندارد")
|
90
|
-
return
|
91
|
-
if uid in ADMINS:
|
92
|
-
ADMINS.remove(uid)
|
93
|
-
save_admins()
|
94
|
-
await message.reply(f"ادمین حذف شد: {uid}")
|
95
|
-
else:
|
96
|
-
await message.reply("کاربر ادمین نیست")
|
97
|
-
except Exception as e:
|
98
|
-
logger.error(f"del_admin_cmd error: {e}")
|
99
|
-
await message.reply(f"خطا: {e}")
|
100
|
-
|
101
|
-
|
102
|
-
async def list_admins_cmd(message):
|
103
|
-
try:
|
104
|
-
if not ADMINS:
|
105
|
-
await message.reply("لیست ادمینها خالی است.")
|
106
|
-
return
|
107
|
-
text = "👑 <b>ADMINS:</b>\n" + "\n".join([str(x) for x in ADMINS])
|
108
|
-
await message.reply(text)
|
109
|
-
except Exception as e:
|
110
|
-
logger.error(f"list_admins_cmd error: {e}")
|
111
|
-
await message.reply(f"خطا: {e}")
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|