radvinshad 1.2.0__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.
radvinshad/__init__.py ADDED
@@ -0,0 +1,6 @@
1
+ """radvinshad — کلاینت شاد خودکفا (شبیه Telethon) + حضور و غیاب"""
2
+ from .client import Client
3
+ from .attendance import Attendance, AttendanceResult
4
+
5
+ __version__ = "1.2.0"
6
+ __all__ = ["Client", "Attendance", "AttendanceResult"]
@@ -0,0 +1,462 @@
1
+ """
2
+ سیستم حضور و غیاب (Present / Absent)
3
+
4
+ دو حالت:
5
+ 1. message → دانش‌آموز اسم و فامیل خودش را در گروه می‌نویسد
6
+ 2. poll → نظرسنجی گذاشته می‌شود و شرکت‌کنندگان با لیست تطبیق داده می‌شوند
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import asyncio
12
+ import re
13
+ from dataclasses import dataclass, field
14
+ from typing import List, Optional, Dict, Set, Literal, Union, Callable, Any
15
+ from difflib import SequenceMatcher
16
+
17
+
18
+ @dataclass
19
+ class AttendanceResult:
20
+ """نتیجه یک جلسه حضور و غیاب"""
21
+ method: str # "message" یا "poll"
22
+ present: List[str] = field(default_factory=list) # کسانی که در لیست بودند و حاضر شدند
23
+ absent: List[str] = field(default_factory=list) # کسانی که در لیست بودند ولی حاضر نشدند
24
+ extra_present: List[str] = field(default_factory=list) # حاضر شدند ولی در لیست نبودند
25
+ pending: List[str] = field(default_factory=list) # موارد مشکوک که نیاز به تأیید دارند
26
+ matched_details: Dict[str, str] = field(default_factory=dict) # نام لیست → متن/شناسه واقعی
27
+
28
+ def summary(self) -> str:
29
+ lines = [
30
+ f"📋 نتیجه حضور و غیاب ({self.method})",
31
+ f"✅ حاضر: {len(self.present)} نفر",
32
+ f"❌ غایب: {len(self.absent)} نفر",
33
+ ]
34
+ if self.extra_present:
35
+ lines.append(f"⚠️ حاضر ولی خارج از لیست: {len(self.extra_present)} نفر")
36
+ if self.pending:
37
+ lines.append(f"⏳ نیاز به بررسی: {len(self.pending)} نفر")
38
+ return "\n".join(lines)
39
+
40
+ def format_absent_message(self) -> str:
41
+ """متن آماده برای اعلام غایبین در گروه"""
42
+ if not self.absent:
43
+ return "✅ همه حاضر هستند. غایبی نداریم."
44
+ lines = ["📢 لیست غایبین:", ""]
45
+ for i, name in enumerate(self.absent, 1):
46
+ lines.append(f"{i}. {name}")
47
+ lines.append("")
48
+ lines.append(f"جمع غایبین: {len(self.absent)} نفر")
49
+ return "\n".join(lines)
50
+
51
+ def format_full_report(self) -> str:
52
+ """گزارش کامل"""
53
+ parts = [self.summary(), ""]
54
+ if self.present:
55
+ parts.append("✅ حاضرین:")
56
+ for n in self.present:
57
+ detail = self.matched_details.get(n, "")
58
+ parts.append(f" • {n}" + (f" ← {detail}" if detail else ""))
59
+ if self.absent:
60
+ parts.append("\n❌ غایبین:")
61
+ for n in self.absent:
62
+ parts.append(f" • {n}")
63
+ if self.extra_present:
64
+ parts.append("\n⚠️ حاضر ولی در لیست نبودند:")
65
+ for n in self.extra_present:
66
+ parts.append(f" • {n}")
67
+ if self.pending:
68
+ parts.append("\n⏳ موارد مشکوک (نیاز به تأیید دستی):")
69
+ for n in self.pending:
70
+ parts.append(f" • {n}")
71
+ return "\n".join(parts)
72
+
73
+
74
+ def _normalize_name(name: str) -> str:
75
+ """نرمال‌سازی اسم برای مقایسه بهتر"""
76
+ name = name.strip()
77
+ # حذف کاراکترهای اضافی رایج
78
+ name = re.sub(r"[_\-\.]+", " ", name)
79
+ name = re.sub(r"\s+", " ", name)
80
+ # تبدیل ی و ک عربی به فارسی
81
+ name = name.replace("ي", "ی").replace("ك", "ک")
82
+ return name.lower()
83
+
84
+
85
+ def _similarity(a: str, b: str) -> float:
86
+ return SequenceMatcher(None, _normalize_name(a), _normalize_name(b)).ratio()
87
+
88
+
89
+ class Attendance:
90
+ """
91
+ مدیریت یک جلسه حضور و غیاب.
92
+
93
+ مثال ساده:
94
+
95
+ att = Attendance(client)
96
+ att.set_list(["علی رضایی", "مریم احمدی", "حسین محمدی"])
97
+
98
+ # حالت پیام
99
+ result = await att.start_message_mode(
100
+ group="g0....",
101
+ duration_seconds=120, # ۲ دقیقه فرصت
102
+ keywords=["حاضر", "حاضرم"] # اختیاری
103
+ )
104
+
105
+ # یا حالت نظرسنجی
106
+ result = await att.start_poll_mode(
107
+ group="g0....",
108
+ question="حضور و غیاب - لطفاً رأی دهید",
109
+ options=["حاضر هستم"],
110
+ wait_seconds=90
111
+ )
112
+
113
+ print(result.format_full_report())
114
+ await client.send_message(group, result.format_absent_message())
115
+ """
116
+
117
+ def __init__(self, client):
118
+ """
119
+ Args:
120
+ client: شیء radvinshad.Client یا maxrubika.Shad
121
+ """
122
+ self.client = client
123
+ self.names: List[str] = []
124
+ self._raw = getattr(client, "raw", client) # دسترسی به maxrubika.Shad
125
+
126
+ # ── مدیریت لیست ──────────────────────────────────────────────
127
+
128
+ def set_list(self, names: List[str]) -> None:
129
+ """تنظیم لیست اسامی (اسم و فامیل)"""
130
+ self.names = [n.strip() for n in names if n and n.strip()]
131
+
132
+ def add_name(self, name: str) -> None:
133
+ name = name.strip()
134
+ if name and name not in self.names:
135
+ self.names.append(name)
136
+
137
+ def remove_name(self, name: str) -> None:
138
+ self.names = [n for n in self.names if n != name]
139
+
140
+ def clear_list(self) -> None:
141
+ self.names.clear()
142
+
143
+ # ── تطبیق اسم ────────────────────────────────────────────────
144
+
145
+ def match_name(
146
+ self,
147
+ text: str,
148
+ threshold: float = 0.72
149
+ ) -> Optional[str]:
150
+ """
151
+ سعی می‌کند متن ورودی را با یکی از اسامی لیست تطبیق دهد.
152
+ اگر شباهت کافی باشد، اسم اصلی لیست را برمی‌گرداند.
153
+ """
154
+ text_norm = _normalize_name(text)
155
+ if not text_norm:
156
+ return None
157
+
158
+ best_name = None
159
+ best_score = 0.0
160
+
161
+ for name in self.names:
162
+ score = _similarity(text, name)
163
+ # اگر متن دقیقاً شامل اسم باشد امتیاز بالاتر
164
+ if _normalize_name(name) in text_norm or text_norm in _normalize_name(name):
165
+ score = max(score, 0.88)
166
+ if score > best_score:
167
+ best_score = score
168
+ best_name = name
169
+
170
+ if best_score >= threshold:
171
+ return best_name
172
+ return None
173
+
174
+ # ── حالت پیام ────────────────────────────────────────────────
175
+
176
+ async def start_message_mode(
177
+ self,
178
+ group: str,
179
+ duration_seconds: int = 120,
180
+ keywords: Optional[List[str]] = None,
181
+ announce: bool = True,
182
+ announce_text: Optional[str] = None,
183
+ similarity_threshold: float = 0.72,
184
+ on_progress: Optional[Callable[[str, str], Any]] = None,
185
+ ) -> AttendanceResult:
186
+ """
187
+ حضور و غیاب با پیام.
188
+
189
+ دانش‌آموزان باید اسم و فامیل خودشان را در گروه بنویسند
190
+ (یا همراه با کلماتی مثل «حاضر»).
191
+
192
+ Args:
193
+ group: guid یا لینک گروه
194
+ duration_seconds: چند ثانیه فرصت بدهند
195
+ keywords: اگر مشخص شود، فقط پیام‌هایی که این کلمات را دارند شمرده می‌شوند
196
+ announce: آیا اول پیام راهنما بفرستد
197
+ announce_text: متن سفارشی راهنما
198
+ similarity_threshold: حداقل شباهت اسم (۰ تا ۱)
199
+ on_progress: تابعی که با هر تشخیص صدا زده می‌شود (name, original_text)
200
+ """
201
+ if not self.names:
202
+ raise ValueError("لیست اسامی خالی است. اول set_list را صدا بزن.")
203
+
204
+ present_map: Dict[str, str] = {} # نام لیست → متن اصلی پیام
205
+ extra: List[str] = []
206
+ seen_guids: Set[str] = set()
207
+
208
+ if announce:
209
+ text = announce_text or (
210
+ "📋 حضور و غیاب شروع شد\n\n"
211
+ "لطفاً ظرف چند دقیقه آینده **اسم و فامیل** خود را در گروه بنویسید.\n"
212
+ "مثال: علی رضایی"
213
+ )
214
+ await self.client.send_message(group, text)
215
+
216
+ # جمع‌آوری پیام‌ها با handler موقت
217
+ collected: List[dict] = []
218
+
219
+ @self._raw.on_message()
220
+ async def _collector(event):
221
+ try:
222
+ chat_guid = getattr(event, "chat_guid", None) or getattr(event, "object_guid", None)
223
+ # فقط پیام‌های همین گروه
224
+ target = await self._raw.get_guid(group) if not group.startswith("g0") else group
225
+ if chat_guid and chat_guid != target:
226
+ return
227
+
228
+ text = (getattr(event, "text", None) or "").strip()
229
+ if not text:
230
+ return
231
+
232
+ author = getattr(event, "author_guid", None) or getattr(event, "author", None)
233
+ collected.append({
234
+ "text": text,
235
+ "author": author,
236
+ "raw": event
237
+ })
238
+ except Exception:
239
+ pass
240
+
241
+ try:
242
+ await asyncio.sleep(duration_seconds)
243
+ finally:
244
+ # حذف handler (اگر کتابخانه پشتیبانی کند)
245
+ try:
246
+ if hasattr(self._raw, "remove_handler"):
247
+ self._raw.remove_handler(_collector)
248
+ except Exception:
249
+ pass
250
+
251
+ # پردازش پیام‌های جمع‌شده
252
+ for item in collected:
253
+ text = item["text"]
254
+ author = item["author"]
255
+
256
+ # اگر keyword تعریف شده، چک کن
257
+ if keywords:
258
+ low = text.lower()
259
+ if not any(k.lower() in low for k in keywords):
260
+ # شاید فقط اسم نوشته، باز هم قبول کن اگر خیلی شبیه لیست باشد
261
+ pass
262
+
263
+ matched = self.match_name(text, threshold=similarity_threshold)
264
+
265
+ if matched:
266
+ if matched not in present_map:
267
+ present_map[matched] = text
268
+ if on_progress:
269
+ try:
270
+ on_progress(matched, text)
271
+ except Exception:
272
+ pass
273
+ else:
274
+ # پیام داده ولی با هیچ اسمی جور نشد
275
+ extra.append(text)
276
+
277
+ present = list(present_map.keys())
278
+ absent = [n for n in self.names if n not in present]
279
+
280
+ result = AttendanceResult(
281
+ method="message",
282
+ present=present,
283
+ absent=absent,
284
+ extra_present=extra,
285
+ matched_details=present_map
286
+ )
287
+ return result
288
+
289
+ # ── حالت نظرسنجی ────────────────────────────────────────────
290
+
291
+ async def start_poll_mode(
292
+ self,
293
+ group: str,
294
+ question: str = "حضور و غیاب — لطفاً رأی دهید",
295
+ options: Optional[List[str]] = None,
296
+ wait_seconds: int = 90,
297
+ is_anonymous: bool = False,
298
+ announce_result: bool = True,
299
+ ) -> AttendanceResult:
300
+ """
301
+ حضور و غیاب با نظرسنجی.
302
+
303
+ توجه: در شاد/روبیکا گرفتن لیست دقیق رأی‌دهندگان همیشه ساده نیست.
304
+ این متد نظرسنجی را می‌فرستد، صبر می‌کند، و بعد سعی می‌کند
305
+ اطلاعات شرکت‌کنندگان را از آپدیت‌ها یا متدهای موجود استخراج کند.
306
+
307
+ اگر کتابخانه پایه اطلاعات رأی‌دهندگان را ندهد،
308
+ فقط از پیام‌های جانبی یا روش ترکیبی استفاده می‌شود.
309
+ """
310
+ if not self.names:
311
+ raise ValueError("لیست اسامی خالی است. اول set_list را صدا بزن.")
312
+
313
+ if options is None:
314
+ options = ["حاضر هستم"]
315
+
316
+ # ارسال نظرسنجی (غیر ناشناس ترجیح داده می‌شود)
317
+ poll_result = await self.client.send_poll(
318
+ chat=group,
319
+ question=question,
320
+ options=options,
321
+ is_anonymous=is_anonymous,
322
+ multiple_answers=False
323
+ )
324
+
325
+ await asyncio.sleep(wait_seconds)
326
+
327
+ # تلاش برای گرفتن اطلاعات رأی‌دهندگان
328
+ # (بسته به نسخه maxrubika ممکن است ساختار متفاوت باشد)
329
+ voters_texts: List[str] = []
330
+ voters_guids: List[str] = []
331
+
332
+ try:
333
+ # اگر نتیجه poll اطلاعات داشته باشد
334
+ if isinstance(poll_result, dict):
335
+ # ساختارهای محتمل
336
+ for key in ("poll", "message", "data", "result"):
337
+ data = poll_result.get(key) if isinstance(poll_result, dict) else None
338
+ if isinstance(data, dict):
339
+ # جستجوی گزینه‌ها و رأی‌دهندگان
340
+ opts = data.get("options") or data.get("poll_options") or []
341
+ for opt in opts:
342
+ if isinstance(opt, dict):
343
+ # بعضی نسخه‌ها لیست کاربران را می‌دهند
344
+ users = opt.get("voters") or opt.get("users") or []
345
+ for u in users:
346
+ if isinstance(u, dict):
347
+ name = u.get("first_name", "") + " " + u.get("last_name", "")
348
+ name = name.strip()
349
+ if name:
350
+ voters_texts.append(name)
351
+ guid = u.get("user_guid") or u.get("guid")
352
+ if guid:
353
+ voters_guids.append(guid)
354
+ except Exception:
355
+ pass
356
+
357
+ # اگر اطلاعات رأی‌دهنده مستقیم نبود، از روش پیام کمکی استفاده می‌کنیم
358
+ # (کاربر می‌تواند بعداً دستی تأیید کند)
359
+ present_map: Dict[str, str] = {}
360
+ extra: List[str] = []
361
+ pending: List[str] = []
362
+
363
+ for text in voters_texts:
364
+ matched = self.match_name(text)
365
+ if matched:
366
+ present_map[matched] = text
367
+ else:
368
+ extra.append(text)
369
+
370
+ # اگر هیچ رأی‌دهنده‌ای پیدا نشد، همه را در pending می‌گذاریم
371
+ # تا کاربر دستی بررسی کند
372
+ if not voters_texts and not voters_guids:
373
+ pending = list(self.names)
374
+
375
+ present = list(present_map.keys())
376
+ absent = [n for n in self.names if n not in present and n not in pending]
377
+
378
+ result = AttendanceResult(
379
+ method="poll",
380
+ present=present,
381
+ absent=absent,
382
+ extra_present=extra,
383
+ pending=pending,
384
+ matched_details=present_map
385
+ )
386
+
387
+ if announce_result:
388
+ await self.client.send_message(group, result.format_absent_message())
389
+
390
+ return result
391
+
392
+ # ── حالت ترکیبی پیشنهادی (بهترین کیفیت) ─────────────────────
393
+
394
+ async def start_hybrid_mode(
395
+ self,
396
+ group: str,
397
+ duration_seconds: int = 150,
398
+ poll_question: str = "حضور و غیاب",
399
+ poll_options: Optional[List[str]] = None,
400
+ similarity_threshold: float = 0.72,
401
+ ) -> AttendanceResult:
402
+ """
403
+ روش پیشنهادی:
404
+ ۱. نظرسنجی می‌فرستد (برای ثبت رسمی)
405
+ ۲. همزمان پیام‌های اسم‌دار را هم جمع می‌کند
406
+ ۳. نتیجه نهایی از روی پیام‌ها ساخته می‌شود (دقیق‌تر است)
407
+ """
408
+ if poll_options is None:
409
+ poll_options = ["حاضر هستم"]
410
+
411
+ # اول نظرسنجی
412
+ try:
413
+ await self.client.send_poll(
414
+ chat=group,
415
+ question=poll_question,
416
+ options=poll_options,
417
+ is_anonymous=False
418
+ )
419
+ except Exception:
420
+ pass
421
+
422
+ # بعد جمع‌آوری پیام‌ها
423
+ return await self.start_message_mode(
424
+ group=group,
425
+ duration_seconds=duration_seconds,
426
+ keywords=None,
427
+ announce=True,
428
+ announce_text=(
429
+ "📋 حضور و غیاب شروع شد\n\n"
430
+ "۱. در نظرسنجی بالا رأی دهید\n"
431
+ "۲. اسم و فامیل خود را هم در گروه بنویسید\n\n"
432
+ "مثال: مریم احمدی"
433
+ ),
434
+ similarity_threshold=similarity_threshold
435
+ )
436
+
437
+ # ── تأیید / رد دستی ──────────────────────────────────────────
438
+
439
+ def confirm(self, result: AttendanceResult, name: str) -> AttendanceResult:
440
+ """تأیید کردن یک نفر مشکوک به عنوان حاضر"""
441
+ if name in result.pending:
442
+ result.pending.remove(name)
443
+ if name not in result.present:
444
+ result.present.append(name)
445
+ if name in result.absent:
446
+ result.absent.remove(name)
447
+ elif name in result.extra_present:
448
+ # از extra به present منتقل کن (اگر خواستی به لیست هم اضافه شود)
449
+ result.extra_present.remove(name)
450
+ if name not in result.present:
451
+ result.present.append(name)
452
+ return result
453
+
454
+ def reject(self, result: AttendanceResult, name: str) -> AttendanceResult:
455
+ """رد کردن یک نفر (غایب حساب شود)"""
456
+ if name in result.pending:
457
+ result.pending.remove(name)
458
+ if name in result.present:
459
+ result.present.remove(name)
460
+ if name not in result.absent and name in self.names:
461
+ result.absent.append(name)
462
+ return result
radvinshad/client.py ADDED
@@ -0,0 +1,205 @@
1
+ """
2
+ radvinshad.Client — API شبیه Telethon برای شاد
3
+ نسخه خودکفا: اول maxrubika.whl داخل پکیج، وگرنه maxrubika نصب‌شده.
4
+ """
5
+ from __future__ import annotations
6
+
7
+ import os
8
+ import sys
9
+ import asyncio
10
+ from typing import Optional, Union, List, Any
11
+
12
+ _HERE = os.path.dirname(os.path.abspath(__file__))
13
+ _WHL = os.path.join(_HERE, "maxrubika.whl")
14
+
15
+ if os.path.isfile(_WHL) and _WHL not in sys.path:
16
+ sys.path.insert(0, _WHL)
17
+
18
+ try:
19
+ from maxrubika import Shad
20
+ except ImportError as e:
21
+ raise ImportError(
22
+ "نتوانست maxrubika را بارگذاری کند.\n"
23
+ "pip install radvinshad یا pip install maxrubika\n"
24
+ f"خطای اصلی: {e}"
25
+ ) from e
26
+
27
+
28
+ class Client:
29
+ """
30
+ کلاینت شاد (سبک Telethon)
31
+
32
+ مثال:
33
+ from radvinshad import Client
34
+ app = Client("my_session")
35
+ async with app:
36
+ await app.send_message("u0....", "سلام")
37
+ await app.lock_group("g0....")
38
+ """
39
+
40
+ def __init__(
41
+ self,
42
+ session: Optional[str] = None,
43
+ auth: Optional[str] = None,
44
+ private_key: Optional[Union[str, bytes]] = None,
45
+ string_session: Optional[str] = None,
46
+ password: Optional[str] = None,
47
+ platform: str = "shad_web",
48
+ api_version: int = 6,
49
+ proxy: Optional[str] = None,
50
+ timeout: Union[int, float] = 30,
51
+ max_retries: int = 5,
52
+ show_welcome: bool = False,
53
+ **kwargs
54
+ ):
55
+ self._shad = Shad(
56
+ session=session,
57
+ auth=auth,
58
+ private_key=private_key,
59
+ string_session=string_session,
60
+ password=password,
61
+ platform=platform,
62
+ api_version=api_version,
63
+ proxy=proxy,
64
+ timeout=timeout,
65
+ max_retries=max_retries,
66
+ show_welcome=show_welcome,
67
+ **kwargs
68
+ )
69
+
70
+ async def start(self, **kwargs):
71
+ if hasattr(self._shad, "start"):
72
+ return await self._shad.start(**kwargs)
73
+ return self
74
+
75
+ async def connect(self):
76
+ if hasattr(self._shad, "connect"):
77
+ return await self._shad.connect()
78
+ return await self.start()
79
+
80
+ async def disconnect(self):
81
+ if hasattr(self._shad, "disconnect"):
82
+ return await self._shad.disconnect()
83
+ if hasattr(self._shad, "stop"):
84
+ return await self._shad.stop()
85
+
86
+ async def stop(self):
87
+ return await self.disconnect()
88
+
89
+ def run(self, coro=None):
90
+ if coro is not None:
91
+ return asyncio.get_event_loop().run_until_complete(coro)
92
+ return self._shad.run()
93
+
94
+ async def __aenter__(self):
95
+ await self.start()
96
+ return self
97
+
98
+ async def __aexit__(self, *args):
99
+ await self.disconnect()
100
+
101
+ def __enter__(self):
102
+ return self._shad.__enter__()
103
+
104
+ def __exit__(self, *args):
105
+ return self._shad.__exit__(*args)
106
+
107
+ async def get_me(self):
108
+ return await self._shad.get_me()
109
+
110
+ @property
111
+ def guid(self):
112
+ return getattr(self._shad, "guid", None)
113
+
114
+ async def send_message(self, entity, message, reply_to=None, **kwargs):
115
+ return await self._shad.send_message(
116
+ chat=entity, text=message, reply_to_message_id=reply_to, **kwargs
117
+ )
118
+
119
+ async def send_photo(self, entity, photo, caption=None, reply_to=None, **kwargs):
120
+ return await self._shad.send_image(
121
+ chat=entity, image=photo, text=caption, reply_to_message_id=reply_to, **kwargs
122
+ )
123
+
124
+ async def send_image(self, entity, image, text=None, reply_to=None, **kwargs):
125
+ return await self._shad.send_image(
126
+ chat=entity, image=image, text=text, reply_to_message_id=reply_to, **kwargs
127
+ )
128
+
129
+ async def send_file(self, entity, file, caption=None, **kwargs):
130
+ return await self._shad.send_file(chat=entity, file=file, text=caption, **kwargs)
131
+
132
+ async def send_poll(self, entity, question, options, is_anonymous=False, multiple_answers=False, **kwargs):
133
+ return await self._shad.send_poll(
134
+ chat=entity, question=question, options=options,
135
+ is_anonymous=is_anonymous, multiple_answers=multiple_answers, **kwargs
136
+ )
137
+
138
+ async def edit_message(self, entity, message_id, text, **kwargs):
139
+ return await self._shad.edit_message(chat=entity, message_id=message_id, text=text, **kwargs)
140
+
141
+ async def delete_messages(self, entity, message_ids, **kwargs):
142
+ if hasattr(self._shad, "delete_messages"):
143
+ return await self._shad.delete_messages(chat=entity, message_ids=message_ids, **kwargs)
144
+ ids = message_ids if isinstance(message_ids, list) else [message_ids]
145
+ return [await self._shad.delete_message(chat=entity, message_id=m, **kwargs) for m in ids]
146
+
147
+ async def lock_group(self, group):
148
+ return await self._shad.lock_group(group)
149
+
150
+ async def unlock_group(self, group):
151
+ return await self._shad.unlock_group(group)
152
+
153
+ async def close_group(self, group):
154
+ return await self.lock_group(group)
155
+
156
+ async def open_group(self, group):
157
+ return await self.unlock_group(group)
158
+
159
+ async def create_group(self, title, **kwargs):
160
+ return await self._shad.create_group(title=title, **kwargs)
161
+
162
+ async def delete_group(self, group, **kwargs):
163
+ return await self._shad.delete_group(group=group, **kwargs)
164
+
165
+ async def join_group(self, group, **kwargs):
166
+ return await self._shad.join_group(group=group, **kwargs)
167
+
168
+ async def leave_group(self, group, **kwargs):
169
+ return await self._shad.leave_group(group=group, **kwargs)
170
+
171
+ async def get_group_info(self, group, **kwargs):
172
+ return await self._shad.get_group_info(group=group, **kwargs)
173
+
174
+ async def get_group_members(self, group, **kwargs):
175
+ return await self._shad.get_group_members(group=group, **kwargs)
176
+
177
+ async def get_group_admins(self, group, **kwargs):
178
+ return await self._shad.get_group_admins(group=group, **kwargs)
179
+
180
+ async def edit_group_title(self, group, title, **kwargs):
181
+ return await self._shad.edit_group_title(group=group, title=title, **kwargs)
182
+
183
+ async def get_group_link(self, group, **kwargs):
184
+ return await self._shad.get_group_link(group=group, **kwargs)
185
+
186
+ async def get_entity(self, entity):
187
+ if hasattr(self._shad, "get_chat_info"):
188
+ return await self._shad.get_chat_info(entity)
189
+ return await self._shad.get_guid(entity)
190
+
191
+ async def get_guid(self, entity):
192
+ return await self._shad.get_guid(entity)
193
+
194
+ def on_message(self, *filters):
195
+ return self._shad.on_message(*filters)
196
+
197
+ def on_new_message(self, *filters):
198
+ return self._shad.on_new_message(*filters)
199
+
200
+ @property
201
+ def raw(self):
202
+ return self._shad
203
+
204
+ def __getattr__(self, name):
205
+ return getattr(self._shad, name)
Binary file
@@ -0,0 +1,64 @@
1
+ Metadata-Version: 2.4
2
+ Name: radvinshad
3
+ Version: 1.2.0
4
+ Summary: Self-contained Shad client (Telethon-like API) + attendance
5
+ Author: radvin
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/radvin/radvinshad
8
+ Keywords: shad,rubika,telethon,userbot,attendance
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.9
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Topic :: Communications :: Chat
17
+ Requires-Python: >=3.9
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: aiohttp
21
+ Requires-Dist: aiofiles
22
+ Requires-Dist: aiosqlite
23
+ Requires-Dist: pycryptodome
24
+ Requires-Dist: rich
25
+ Requires-Dist: mutagen
26
+ Dynamic: license-file
27
+
28
+ # radvinshad
29
+
30
+
31
+ ## نصب
32
+
33
+ ```bash
34
+ pip install radvinshad
35
+ ```
36
+
37
+
38
+ ## مثال
39
+
40
+ ```python
41
+ import asyncio
42
+ from radvinshad import Client
43
+
44
+ async def main():
45
+ app = Client("my_session")
46
+ async with app:
47
+ await app.send_message("u0xxxx", "سلام")
48
+ await app.lock_group("g0xxxx")
49
+ await app.send_poll("g0xxxx", "حاضرید؟", ["بله"])
50
+
51
+ asyncio.run(main())
52
+ ```
53
+
54
+ ## امکانات
55
+
56
+ - پیام پیوی و گروه
57
+ - عکس و فایل
58
+ - نظرسنجی + خواندن رأی‌دهندگان
59
+ - قفل / باز کردن گروه
60
+ - حضور و غیاب (فارسی و انگلیسی)
61
+
62
+ ## انتشار از سورس
63
+
64
+
@@ -0,0 +1,9 @@
1
+ radvinshad/__init__.py,sha256=ZC2j-kXHUbAEzwvWgVmbp47zdBWJqunJqFPMQ7qjYFQ,255
2
+ radvinshad/attendance.py,sha256=GXPbghu65xjvoxQat4pUukmr2p9J4KXkj6UbsBviV7U,19185
3
+ radvinshad/client.py,sha256=nv2iz7uMz-ntMNa2yYZYLPmpl5slz0jItyR29_U6x9g,6892
4
+ radvinshad/maxrubika.whl,sha256=xWPusXd3P3BviOTPtS9NxCL5KfvnzAxavo-8syDh_7E,572334
5
+ radvinshad-1.2.0.dist-info/licenses/LICENSE,sha256=YcgQi-iFLZow3k3A4qotapFxggwGsJdkyDCt7VQHOSo,1063
6
+ radvinshad-1.2.0.dist-info/METADATA,sha256=sRADI_THvhNmFoUBV1m-PwsPIJaWCHYM_8IVHhpWl-M,1607
7
+ radvinshad-1.2.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
8
+ radvinshad-1.2.0.dist-info/top_level.txt,sha256=Se8EX9po8tL_TFxutZSM3xSu7528KrHZydAM95mDSn8,11
9
+ radvinshad-1.2.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 radvin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ radvinshad