This commit is contained in:
2026-11-11 18:07:00 +03:30
parent ee6ae89001
commit 427e2ecd89
6 changed files with 598 additions and 4 deletions
+581
View File
@@ -0,0 +1,581 @@
<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>مستند فنی پیاده‌سازی سرویس نوتیفیکیشن بله | یکپارچه‌سازی با xFramework</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800&display=swap');
:root {
--primary: #1a365d;
--primary-light: #2c5282;
--accent: #c9a961;
--accent-dark: #a8893f;
--bg: #faf9f6;
--card-bg: #ffffff;
--text: #1a202c;
--text-muted: #4a5568;
--border: #e2e8f0;
--success: #38a169;
--danger: #e53e3e;
--warning: #dd6b20;
--shadow: 0 4px 6px rgba(0,0,0,0.05), 0 10px 30px rgba(26,54,93,0.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: 'Vazirmatn', Tahoma, sans-serif;
background: var(--bg);
color: var(--text);
line-height: 1.9;
font-size: 15px;
padding: 30px 15px;
}
.document-container {
max-width: 950px;
margin: 0 auto;
background: var(--card-bg);
box-shadow: var(--shadow);
border-radius: 12px;
overflow: hidden;
}
.document-header {
background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
color: white;
padding: 50px 40px 40px;
position: relative;
border-bottom: 4px solid var(--accent);
}
.document-header::before {
content: '';
position: absolute;
top: 0; right: 0;
width: 200px; height: 200px;
background: radial-gradient(circle, rgba(201,169,97,0.15) 0%, transparent 70%);
border-radius: 50%;
transform: translate(50%, -50%);
}
.header-top {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 30px;
position: relative;
z-index: 1;
}
.company-badge {
display: flex;
align-items: center;
gap: 12px;
}
.company-logo {
width: 60px; height: 60px;
background: var(--accent);
border-radius: 12px;
box-shadow: 0 4px 12px rgba(0,0,0,0.2);
display: flex;
align-items: center;
justify-content: center;
font-weight: 800;
color: white;
font-size: 14px;
}
.doc-meta {
text-align: left;
font-size: 12px;
opacity: 0.9;
}
.doc-meta div { margin-bottom: 3px; }
.document-title {
text-align: center;
position: relative;
z-index: 1;
padding: 20px 0;
}
.document-title .label {
display: inline-block;
background: rgba(201,169,97,0.2);
color: var(--accent);
padding: 4px 16px;
border-radius: 20px;
font-size: 12px;
font-weight: 600;
margin-bottom: 15px;
border: 1px solid rgba(201,169,97,0.4);
}
.document-title h1 {
font-size: 28px;
font-weight: 800;
margin-bottom: 10px;
letter-spacing: -0.5px;
}
.document-title h2 {
font-size: 16px;
font-weight: 400;
opacity: 0.9;
}
.document-body {
padding: 40px;
}
.intro-text {
background: linear-gradient(to left, #f7fafc, #edf2f7);
border-right: 4px solid var(--accent);
padding: 20px 25px;
border-radius: 8px;
margin-bottom: 35px;
font-size: 14px;
color: var(--text-muted);
}
.section {
margin-bottom: 40px;
page-break-inside: avoid;
}
.section-header {
display: flex;
align-items: center;
gap: 15px;
padding-bottom: 12px;
border-bottom: 2px solid var(--border);
margin-bottom: 20px;
}
.section-number {
width: 50px; height: 50px;
background: linear-gradient(135deg, var(--primary), var(--primary-light));
color: white;
border-radius: 12px;
display: flex;
align-items: center;
justify-content: center;
font-weight: 800;
font-size: 20px;
flex-shrink: 0;
box-shadow: 0 4px 10px rgba(26,54,93,0.2);
}
.section-title { flex: 1; }
.section-title h3 {
font-size: 19px;
font-weight: 700;
color: var(--primary);
margin-bottom: 2px;
}
.section-title .subtitle {
font-size: 12px;
color: var(--text-muted);
}
.section-content {
padding-right: 10px;
}
.section-content p {
margin-bottom: 12px;
text-align: justify;
text-indent: 20px;
}
.section-content p.no-indent { text-indent: 0; }
.highlight-box {
background: linear-gradient(to left, #fffaf0, #fef5e7);
border: 1px solid #f6e05e;
border-right: 4px solid var(--accent);
padding: 18px 22px;
border-radius: 8px;
margin: 20px 0;
font-size: 14px;
}
.highlight-box strong { color: var(--accent-dark); }
.info-box {
background: linear-gradient(to left, #ebf8ff, #e6f6ff);
border: 1px solid #90cdf4;
border-right: 4px solid var(--primary-light);
padding: 18px 22px;
border-radius: 8px;
margin: 20px 0;
font-size: 14px;
}
.success-box {
background: linear-gradient(to left, #f0fff4, #e6fffa);
border: 1px solid #9ae6b4;
border-right: 4px solid var(--success);
padding: 18px 22px;
border-radius: 8px;
margin: 20px 0;
font-size: 14px;
}
.warning-box {
background: linear-gradient(to left, #fffaf0, #fef5e7);
border: 1px solid #fbd38d;
border-right: 4px solid var(--warning);
padding: 18px 22px;
border-radius: 8px;
margin: 20px 0;
font-size: 14px;
}
.styled-table {
width: 100%;
border-collapse: collapse;
margin: 20px 0;
background: white;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.styled-table thead {
background: linear-gradient(135deg, var(--primary), var(--primary-light));
color: white;
}
.styled-table th {
padding: 14px 16px;
text-align: right;
font-weight: 600;
font-size: 13px;
}
.styled-table td {
padding: 13px 16px;
border-bottom: 1px solid var(--border);
font-size: 13px;
}
.styled-table tbody tr:last-child td { border-bottom: none; }
.styled-table tbody tr:nth-child(even) { background: #f8fafc; }
.styled-table .highlight-row {
background: #fffaf0 !important;
font-weight: 600;
}
.code-block {
background: #1a202c;
color: #e2e8f0;
padding: 20px;
border-radius: 8px;
font-family: 'Consolas', 'Monaco', monospace;
font-size: 13px;
direction: ltr;
text-align: left;
overflow-x: auto;
margin: 20px 0;
border-right: 4px solid var(--accent);
}
.code-block .keyword { color: #569cd6; }
.code-block .string { color: #ce9178; }
.code-block .comment { color: #6a9955; }
.code-block .type { color: #4ec9b0; }
.comparison-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
margin: 25px 0;
}
.comparison-card {
background: #f8fafc;
border: 2px solid var(--border);
border-radius: 10px;
padding: 20px;
position: relative;
}
.comparison-card.recommended {
border-color: var(--success);
background: linear-gradient(to left, #f0fff4, #e6fffa);
}
.comparison-card .card-badge {
position: absolute;
top: -10px;
right: 20px;
background: var(--success);
color: white;
padding: 3px 12px;
border-radius: 15px;
font-size: 11px;
font-weight: 600;
}
.comparison-card h4 {
font-size: 16px;
font-weight: 700;
color: var(--primary);
margin-bottom: 15px;
padding-bottom: 10px;
border-bottom: 2px solid var(--border);
}
.comparison-card.recommended h4 { border-bottom-color: var(--success); }
.comparison-card ul { list-style: none; padding: 0; }
.comparison-card ul li {
padding: 8px 0;
border-bottom: 1px solid var(--border);
font-size: 13px;
display: flex;
justify-content: space-between;
}
.comparison-card ul li:last-child { border-bottom: none; }
.comparison-card ul li .value { font-weight: 600; color: var(--primary); }
.stats-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 15px;
margin: 25px 0;
}
.stat-card {
background: linear-gradient(135deg, var(--primary), var(--primary-light));
color: white;
padding: 20px;
border-radius: 10px;
text-align: center;
box-shadow: 0 4px 12px rgba(26,54,93,0.2);
}
.stat-card .stat-value {
font-size: 24px;
font-weight: 800;
margin-bottom: 5px;
color: var(--accent);
line-height: 1.3;
}
.stat-card .stat-label { font-size: 12px; opacity: 0.9; }
.conclusion-box {
background: linear-gradient(135deg, var(--primary), var(--primary-light));
color: white;
padding: 30px;
border-radius: 12px;
margin: 30px 0;
text-align: center;
box-shadow: 0 8px 20px rgba(26,54,93,0.3);
}
.conclusion-box h3 {
font-size: 22px;
font-weight: 800;
margin-bottom: 15px;
color: var(--accent);
}
.conclusion-box p {
font-size: 14px;
line-height: 1.8;
text-indent: 0 !important;
margin-bottom: 15px;
}
.conclusion-box .highlight {
background: rgba(201,169,97,0.2);
padding: 15px 20px;
border-radius: 8px;
margin-top: 20px;
border: 1px solid rgba(201,169,97,0.4);
}
.document-footer {
background: var(--primary);
color: white;
padding: 25px 40px;
text-align: center;
font-size: 12px;
margin-top: 40px;
}
.document-footer .footer-brand {
font-weight: 700;
color: var(--accent);
margin-bottom: 5px;
font-size: 14px;
}
.footer-divider {
width: 60px;
height: 2px;
background: var(--accent);
margin: 10px auto;
}
.page-info {
text-align: center;
padding: 15px;
font-size: 11px;
color: var(--text-muted);
border-top: 1px solid var(--border);
margin-top: 30px;
}
@media print {
body { background: white; padding: 0; }
.document-container { box-shadow: none; border-radius: 0; }
.section { page-break-inside: avoid; }
}
@media (max-width: 768px) {
.document-body { padding: 25px 20px; }
.document-header { padding: 30px 20px; }
.comparison-grid { grid-template-columns: 1fr; }
.stats-grid { grid-template-columns: 1fr; }
.header-top { flex-direction: column; gap: 15px; }
.doc-meta { text-align: center; }
}
</style>
</head>
<body>
<div class="document-container">
<header class="document-header">
<div class="header-top">
<div class="company-badge">
<div class="company-logo">RPK</div>
</div>
<div class="doc-meta">
<div>شماره مستند: TECH-1405-004</div>
<div>نسخه: ۱.۰</div>
<div>تاریخ تهیه: آبان ۱۴۰۵</div>
<div>طبقه‌بندی: داخلی / فنی</div>
</div>
</div>
<div class="document-title">
<span class="label">TECHNICAL GUIDE</span>
<h1>راهنمای جامع پیاده‌سازی سرویس نوتیفیکیشن بله</h1>
<h2>یکپارچه‌سازی Bot API با ماژول‌های xBotService و xHttpService</h2>
</div>
</header>
<div class="document-body">
<div class="intro-text">
<strong>مدیر انتشار و تیم توسعه محترم،</strong><br>
این مستند فنی، راهنمای گام‌به‌گام طراحی و پیاده‌سازی یک سیستم کامل مدیریت بات بله را ارائه می‌دهد. در این معماری، از زیرساخت موجود <code>xBotService</code> برای ذخیره‌سازی کاربران و از <code>xHttpService</code> برای برقراری ارتباط با سرورهای بله استفاده خواهد شد.
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۱</div>
<div class="section-title">
<h3>خلاصه اجرایی و معماری یکپارچه</h3>
<div class="subtitle">Executive Summary & Integrated Architecture</div>
</div>
</div>
<div class="section-content">
<p>هدف نهایی، ایجاد یک چرخه کامل تعامل است که شامل سه بخش اصلی می‌باشد:</p>
<div class="stats-grid">
<div class="stat-card">
<div class="stat-value">عضویت<br>و ثبت</div>
<div class="stat-label">ذخیره Chat ID کاربران در xBotUser</div>
</div>
<div class="stat-card">
<div class="stat-value">ارسال<br>پیام</div>
<div class="stat-label">استفاده از xHttpProvider برای ارسال نوتیف</div>
</div>
<div class="stat-card">
<div class="stat-value">دریافت<br>و پردازش</div>
<div class="stat-label">مدیریت پیام‌های ورودی کاربران</div>
</div>
</div>
<div class="highlight-box">
<strong>نتیجه کلیدی:</strong> با استفاده از الگوی Repository موجود در <code>xBotService</code> و سرویس HTTP استاندارد، یک سیستم پایدار و مقیاس‌پذیر بدون نیاز به کتابخانه‌های جانبی سنگین پیاده‌سازی می‌کنیم.
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۲</div>
<div class="section-title">
<h3>گام اول: مدیریت عضویت و ذخیره در xBotUser</h3>
<div class="subtitle">Membership Management & xBotUser Storage</div>
</div>
</div>
<div class="section-content">
<p>برای ثبت شناسه بله کاربران، از مدل <code>XBotUser</code> موجود در ماژول <code>xBotService</code> استفاده می‌کنیم. فیلد <code>UserId</code> برای شناسه کاربر سیستم و <code>BotUserName</code> برای شناسه بله (Chat ID) در نظر گرفته می‌شود.</p>
<div class="code-block">
<span class="keyword">public class</span> <span class="type">BaleMembershipService</span>
{
<span class="keyword">private readonly</span> <span class="type">IXBotUserRepositoryService</span> _botRepo;
<span class="keyword">public async</span> <span class="type">Task</span> <span class="type">RegisterUserAsync</span>(<span class="keyword">string</span> systemUserId, <span class="keyword">long</span> baleChatId)
{
<span class="keyword">var</span> entity = <span class="keyword">new</span> <span class="type">XBotUser</span>
{
UserId = systemUserId,
BotUserName = baleChatId.ToString() <span class="comment">// ذخیره Chat ID بله</span>
};
<span class="keyword">await</span> _botRepo.AddAsync(entity);
}
}
</div>
<div class="info-box">
<strong>💡 نکته مهم:</strong> هنگام دریافت دستور <code>/start</code> از کاربر، باید <code>Chat ID</code> استخراج شده از آپدیت بله را در فیلد <code>BotUserName</code> ذخیره نمایید.
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۳</div>
<div class="section-title">
<h3>گام دوم: ارسال نوتیفیکیشن با xHttpProvider</h3>
<div class="subtitle">Sending Notifications via xHttpProvider</div>
</div>
</div>
<div class="section-content">
<p>برای ارسال پیام، از سرویس <code>IXHttpProvider</code> استفاده می‌کنیم تا درخواست‌های POST را به آدرس <code>tapi.bale.ai</code> ارسال کنیم.</p>
<div class="code-block">
<span class="keyword">public class</span> <span class="type">BaleNotificationService</span>
{
<span class="keyword">private readonly</span> <span class="type">IXHttpProvider</span> _httpProvider;
<span class="keyword">private readonly</span> <span class="keyword">string</span> _botToken;
<span class="keyword">public async</span> <span class="type">Task</span> <span class="type">SendAlertAsync</span>(<span class="keyword">long</span> chatId, <span class="keyword">string</span> message)
{
<span class="keyword">var</span> client = _httpProvider.GetRestClient(<span class="string">"https://tapi.bale.ai"</span>);
<span class="keyword">var</span> request = _httpProvider.GetRestRequet($<span class="string">"/bot{_botToken}/sendMessage"</span>);
request.AddJsonBody(<span class="keyword">new</span> { chat_id = chatId, text = message });
<span class="keyword">await</span> _httpProvider.RunRestRequest&lt;<span class="keyword">object</span>&gt;(client, request, <span class="type">XHttpMethod</span>.POST);
}
}
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۴</div>
<div class="section-title">
<h3>گام سوم: دریافت و پردازش پیام‌های ورودی</h3>
<div class="subtitle">Receiving & Processing Incoming Messages</div>
</div>
</div>
<div class="section-content">
<p>برای دریافت پیام‌ها، یک <code>BackgroundService</code> ایجاد می‌کنیم که متد <code>getUpdates</code> بله را فراخوانی کرده و پس از پردازش، آن‌ها را در دیتابیس لاگ یا پاسخ دهد.</p>
<div class="code-block">
<span class="keyword">protected override async</span> <span class="type">Task</span> <span class="type">ExecuteAsync</span>(<span class="type">CancellationToken</span> ct)
{
<span class="keyword">while</span> (!ct.IsCancellationRequested)
{
<span class="keyword">var</span> updates = <span class="keyword">await</span> GetBaleUpdatesAsync();
<span class="keyword">foreach</span> (<span class="keyword">var</span> update <span class="keyword">in</span> updates)
{
<span class="keyword">if</span> (update.Message != <span class="keyword">null</span>)
<span class="keyword">await</span> ProcessIncomingMessage(update.Message);
}
<span class="keyword">await</span> <span class="type">Task</span>.Delay(1000, ct);
}
}
</div>
<div class="success-box">
<strong>✓ مزیت معماری:</strong> جداسازی لایه دریافت پیام از لایه ذخیره‌سازی (xBotService) باعث می‌شود سیستم در برابر حجم بالای پیام‌ها مقاوم باشد.
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۵</div>
<div class="section-title">
<h3>جمع‌بندی و گام بعدی</h3>
<div class="subtitle">Final Summary & Next Steps</div>
</div>
</div>
<div class="section-content">
<div class="conclusion-box">
<h3>🎯 مسیر پیشنهادی</h3>
<p>با ترکیب قدرت <strong>xBotService</strong> برای مدیریت داده‌ها و <strong>xHttpService</strong> برای ارتباطات، شما یک زیرساخت حرفه‌ای برای مدیریت بات بله در اختیار خواهید داشت.</p>
<div class="highlight">
<strong>💎 ارزش فنی:</strong><br>
استفاده از استانداردهای سازمانی + کاهش وابستگی‌های خارجی + قابلیت توسعه آسان
</div>
</div>
<div class="info-box">
<strong>📞 گام بعدی:</strong> در صورت تأیید، می‌توانم کدهای کامل Controller و Service‌های مرتبط را بر اساس این ساختار آماده کنم.
</div>
</div>
</div>
<div class="page-info">
این مستند فنی محرمانه بوده و صرفاً جهت استفاده داخلی تیم توسعه شرکت رایان پرداز کاوش تهیه شده است.
</div>
</div>
<footer class="document-footer">
<div class="footer-brand">طراحی و تدوین: هادی خزاعی اصل | مدیر انتشار</div>
<div class="footer-divider"></div>
<div>تاریخ تهیه: آبان ۱۴۰۵ &nbsp;|&nbsp; نسخه: ۱.۰ &nbsp;|&nbsp; طبقه‌بندی: داخلی / فنی</div>
</footer>
</div>
</body>
</html>
+13
View File
@@ -0,0 +1,13 @@
✅ بازوی شما با موفقیت ساخته شد!
🔹 نام بازو: @xSaherElmBot
🔹 لینک دسترسی: ble.ir/xSaherElmBot
🔹 توکن دسترسی:
57317004:D2I9H0KWq2rTB44hHlZ7fOCa9oTgUU6RGIg
📌 نکته امنیتی:
توکن بازو کلید دسترسی کامل به آن است؛ لطفاً آن را مانند یک رمز عبور محرمانه نگه‌داری کنید.
📌 نکته:
بازوها زمانی در جستجوی بله قابل مشاهده هستند که بالای ۲۰ کاربر ماهانه داشته باشند.
+1 -1
Submodule xApi updated: 374c3258ef...f013a46362