Skip to content

feat: RustChain Telegram Community Bot (#249, 50 RTC) - #1495

Closed
kuanglaodi2-sudo wants to merge 3 commits into
Scottcjn:mainfrom
kuanglaodi2-sudo:feature/telegram-community-bot
Closed

kuanglaodi2-sudo wants to merge 3 commits into
Scottcjn:mainfrom
kuanglaodi2-sudo:feature/telegram-community-bot

Conversation

@kuanglaodi2-sudo

Copy link
Copy Markdown
Contributor

RustChain Telegram Community Bot (#249, 50 RTC)

Bounty: #249 — RustChain Telegram Community Bot
Claim: Scottcjn/rustchain-bounties#249 (comment)
Author: kuanglaodi2-sudo
Wallet: C4c7r9WPsnEe6CUfegMU9M7ReHD1pWg8qeSfTBoRcLbg


What Was Built

Directory: tools/telegram_bot/

A production-ready Telegram bot for the RustChain community.

Commands Implemented

Command Description
/start Welcome + inline keyboard menu
/price Current wRTC/SOL price from Raydium
/miners Active miner count + top 5 miners by antiquity
/epoch Current epoch #, start/end, blocks, reward
/balance <addr> RTC wallet balance
/health Node health, uptime, peers, block height
/stats Full network dashboard
/alerts Subscribe/unsubscribe to mining alerts

Bonus Features

  • ✅ Mining Alerts — Background job polls every 60s, notifies subscribers on new epochs
  • ✅ Epoch Settlement Alerts — Instant notification when epoch changes
  • ✅ Alert Subscription System — Users opt-in/out with /alerts command

Files

tools/telegram_bot/
├── bot.py              (~15KB) — Main bot, all command handlers
├── api.py              (~6KB)  — Async RustChain API client (aiohttp)
├── requirements.txt     — Dependencies: python-telegram-bot, aiohttp, python-dotenv
├── .env.example        — Environment template
├── Dockerfile           — Container build (python:3.11-slim)
├── rustchain_bot.service — systemd unit file
└── README.md           — Full setup + deployment guide

API Integration

Command RustChain API
/miners GET /api/miners
/epoch GET /epoch
/balance GET /balance/<wallet>
/health GET /health
/stats GET /api/stats
/price Raydium DEX API (wRTC/SOL)

Deployment

# 1. Get token from @BotFather
# 2. pip install -r requirements.txt
# 3. cp .env.example .env && add TELEGRAM_BOT_TOKEN
# 4. python bot.py

# Or Docker:
docker build -t rustchain-telegram-bot .
docker run -d --env-file .env rustchain-telegram-bot

# Or systemd:
sudo cp rustchain_bot.service /etc/systemd/system/
sudo systemctl enable rustchain_bot && sudo systemctl start rustchain_bot

Bot Features

  • Styled HTML responses (bold, code, emojis)
  • Graceful error handling + API fallbacks
  • Background alert job (60s polling interval)
  • Inline keyboard menus
  • Structured logging with configurable level

kuanglaodi2-sudo and others added 3 commits March 14, 2026 22:42
- Implements GET /wallet/history?miner_id=X&limit=50&offset=0
- Returns transaction history including rewards and transfers
- Queries epoch_rewards table for mining rewards
- Queries ledger table for transfers
- Supports pagination with limit and offset parameters
… fingerprint checks

Adds arch_cross_validation.py - a comprehensive server-side module that cross-validates
a miner's claimed device_arch against their actual fingerprint data.

Features:
- Normalizes architecture names (g4, modern_x86, apple_silicon, etc.)
- Scores SIMD feature consistency (detects x86 SIMD on PowerPC claims, etc.)
- Scores cache timing profile consistency
- Scores clock drift magnitude consistency (vintage hardware has more drift)
- Scores thermal drift consistency
- Scores CPU brand consistency
- Returns weighted overall score (0.0-1.0) with detailed breakdown
- Handles the 'frozen profile' case (cv=0, VM/emulator fingerprint)

Includes unit tests covering:
- Real hardware validation (G4, modern_x86, apple_silicon)
- Spoofing detection (x86 claiming G4)
- Frozen/noisy profile detection
- Empty fingerprint handling
- CPU brand consistency

Fixes: Scottcjn/rustchain-bounties#17
Bounty: 50 RTC
- Python Telegram bot (python-telegram-bot v20)
- Commands: /price, /miners, /epoch, /balance, /health, /stats, /alerts
- Async RustChain API client (aiohttp)
- Alert subscription system (epoch alerts every 60s)
- Docker + systemd deployment ready
- Structured HTML-formatted responses with inline keyboards

Bounty: Scottcjn/rustchain-bounties#249
Claim: Scottcjn/rustchain-bounties#249 (comment)
Author: kuanglaodi2-sudo
@github-actions

Copy link
Copy Markdown
Contributor

Welcome to RustChain! Thanks for your first pull request.

Before we review, please make sure:

  • Your PR has a BCOS-L1 or BCOS-L2 label
  • New code files include an SPDX license header
  • You've tested your changes against the live node

Bounty tiers: Micro (1-10 RTC) | Standard (20-50) | Major (75-100) | Critical (100-150)

A maintainer will review your PR soon. Thanks for contributing!

@github-actions github-actions Bot added documentation Improvements or additions to documentation BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) BCOS-L2 Beacon Certified Open Source tier BCOS-L2 (required for non-doc PRs) wallet Wallet/transfer related node Node server related api API endpoint related size/XL PR: 500+ lines labels Mar 19, 2026
@Scottcjn

Copy link
Copy Markdown
Owner

@kuanglaodi2-sudo — 30,327 additions / 28,724 deletions. 5th PR with the full-repo reformat. We cannot review these. Fix your editor settings — turn off auto-formatting, turn off line-ending conversion. Then submit ONLY new files.

@Scottcjn Scottcjn closed this Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api API endpoint related BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) BCOS-L2 Beacon Certified Open Source tier BCOS-L2 (required for non-doc PRs) documentation Improvements or additions to documentation node Node server related size/XL PR: 500+ lines wallet Wallet/transfer related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants