Skip to content

Complete Telegram bot commands for RustChain status#4863

Open
dazer1234 wants to merge 2 commits into
Scottcjn:mainfrom
dazer1234:codex/telegram-bot-bounty-2869
Open

Complete Telegram bot commands for RustChain status#4863
dazer1234 wants to merge 2 commits into
Scottcjn:mainfrom
dazer1234:codex/telegram-bot-bounty-2869

Conversation

@dazer1234
Copy link
Copy Markdown

Summary

  • updates the existing RustChain Telegram bot to match rustchain-bounties#2869
  • adds /miners and /price commands
  • changes rate limiting to enforce a configurable 1 request per 5 seconds per user while keeping the per-minute cap
  • adds Railway, Fly.io, and systemd deployment instructions
  • expands tests for the new commands and throttle behavior

RTC wallet: dazer1234

Validation

  • python -m pytest telegram_bot\tests -q
  • live client smoke test against https://50.28.86.131: /health, /epoch, /api/miners

Implemented with OpenAI Codex assistance.

@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) size/L PR: 201-500 lines labels May 12, 2026
@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!

Copy link
Copy Markdown
Contributor

@508704820 508704820 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review: Complete Telegram Bot Commands for RustChain Status

Summary

Adds /miners and /price commands to the RustChain Telegram bot, plus rate limiting window and RTC reference rate configuration.

What Works Well

  1. New /miners command: Lists active miners with status fields
  2. New /price command: Shows RTC reference rate in USD
  3. Rate limiting improvement: Added RATE_LIMIT_WINDOW_SECONDS for per-user cooldown
  4. Configurable reference rate: RTC_REFERENCE_RATE_USD in .env
  5. README updated: New commands documented in table

Issues Found

1. Low — Hardcoded reference rate source
The price command uses a configured RTC_REFERENCE_RATE_USD from .env (default $0.10). This is not a live market price. Consider fetching from an API or clearly labeling it as a "reference rate" not "market price" to avoid confusion.

2. Nit — Rate limit window naming
RATE_LIMIT_PER_MINUTE and RATE_LIMIT_WINDOW_SECONDS could conflict. If a user sends 10 requests in 1 minute (within per-minute limit) but within 5-second windows, which takes precedence? Clarify the interaction.

Verdict: Approve

Good feature additions. The reference rate disclaimer is the main concern.

Copy link
Copy Markdown

@saim256 saim256 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving current head b773e47.

The PR completes the missing /miners and /price commands for the existing Telegram bot, keeps the older per-minute limit while adding the requested 5-second per-user throttle, and updates the README/.env deployment guidance. The /price copy correctly calls this a reference rate rather than a market quote.

Validation performed:

  • python -m pytest telegram_bot\tests -q initially failed because python-telegram-bot was not installed in this local environment
  • installed missing local test dependencies: python -m pip install --user python-telegram-bot pytest-asyncio
  • python -m pytest telegram_bot\tests -q -> 31 passed
  • python -m py_compile telegram_bot\rustchain_query_bot.py telegram_bot\tests\test_bot_commands.py telegram_bot\tests\test_rustchain_client.py -> passed
  • python tools\bcos_spdx_check.py --base-ref origin/main -> BCOS SPDX check: OK
  • git diff --check origin/main...HEAD -- telegram_bot/.env.example telegram_bot/README.md telegram_bot/rustchain_query_bot.py telegram_bot/tests/test_bot_commands.py telegram_bot/tests/test_rustchain_client.py -> passed

Copy link
Copy Markdown
Contributor

@godd-ctrl godd-ctrl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved current head b773e4747b008645c00d371f03399d17e174ee4a.

The new Telegram commands are registered, documented, and covered by focused tests. /miners normalizes supported API response shapes and limits output to a manageable list; /price is read-only and environment-configurable. The expanded rate limiter is covered by the client tests.

Validation performed:

  • git diff --name-status origin/main...HEAD -> telegram_bot files only
  • git diff --check origin/main...HEAD -> passed
  • python tools\bcos_spdx_check.py --base-ref origin/main -> passed
  • python -m py_compile telegram_bot\rustchain_query_bot.py telegram_bot\tests\test_bot_commands.py telegram_bot\tests\test_rustchain_client.py -> passed
  • Initial pytest failed because python-telegram-bot was not installed in this environment
  • Installed declared test/runtime dependencies into temporary C:\tmp\review-pydeps-telegram
  • PYTHONPATH=C:\tmp\review-pydeps-telegram;telegram_bot python -m pytest telegram_bot\tests -q -> 31 passed

No blocking issues found in the reviewed diff.

@dazer1234
Copy link
Copy Markdown
Author

Follow-up for the review feedback:

  • /price now explicitly labels the value as the RTC bounty reference rate, not a live market quote.
  • Replaced the ambiguous RATE_LIMIT_WINDOW_SECONDS docs/config surface with RATE_LIMIT_COOLDOWN_SECONDS while keeping the old env var as a backwards-compatible fallback.
  • Added a test assertion that /price states it does not fetch/report live market price data.

Validation: python -m pytest telegram_bot\tests -q -> 31 passed.

Copy link
Copy Markdown
Contributor

@jaxint jaxint left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for contributing. Approved.

Copy link
Copy Markdown

@saim256 saim256 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved current head 0e5cc95.

The follow-up resolves the ambiguity from the earlier review: /price now clearly presents an RTC bounty reference rate rather than a live market quote, adds a regression assertion for that wording, and renames the cooldown configuration to RATE_LIMIT_COOLDOWN_SECONDS while preserving RATE_LIMIT_WINDOW_SECONDS as a backwards-compatible fallback. The README and .env.example now use the clearer public names.

Validation performed locally:

  • python -m pytest telegram_bot\tests -q -> 31 passed
  • python -m py_compile telegram_bot\rustchain_query_bot.py telegram_bot\tests\test_bot_commands.py telegram_bot\tests\test_rustchain_client.py -> passed
  • git diff --check origin/main...HEAD -- telegram_bot/.env.example telegram_bot/README.md telegram_bot/rustchain_query_bot.py telegram_bot/tests/test_bot_commands.py telegram_bot/tests/test_rustchain_client.py -> passed
  • python tools\bcos_spdx_check.py --base-ref origin/main -> BCOS SPDX check: OK
  • rg confirmed the new env names are documented and the legacy env names remain only as code fallbacks

No blocking issues found.

Copy link
Copy Markdown
Contributor

@jaxint jaxint left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great contribution! LGTM.

Copy link
Copy Markdown
Contributor

@jaxint jaxint left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great contribution! LGTM.

Copy link
Copy Markdown
Contributor

@jaxint jaxint left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great contribution! LGTM.

Copy link
Copy Markdown
Contributor

@jaxint jaxint left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great contribution! LGTM.

Copy link
Copy Markdown
Contributor

@jaxint jaxint left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great contribution! LGTM.

Copy link
Copy Markdown
Contributor

@jaxint jaxint left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great contribution! LGTM.

Copy link
Copy Markdown

@loganoe loganoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review for Scottcjn/rustchain-bounties#73 on current head 0e5cc950be306c154b62b0826a4e98552fdb8d06.

The Telegram bot update now closes the earlier ambiguity around /price: it labels the value as the RTC bounty reference rate rather than a live market quote, keeps the legacy rate-limit env name only as a fallback, and documents the clearer RATE_LIMIT_COOLDOWN_SECONDS surface. The /miners and /price command coverage is included with the existing bot command tests.

Validation performed:

  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --no-project --with pytest --with pytest-asyncio --with python-telegram-bot --with requests --with python-dotenv python -m pytest -p pytest_asyncio.plugin telegram_bot/tests -q -> 31 passed
  • python3 -m py_compile telegram_bot/rustchain_query_bot.py telegram_bot/tests/test_bot_commands.py telegram_bot/tests/test_rustchain_client.py -> passed
  • git diff --check origin/main...HEAD -- telegram_bot/.env.example telegram_bot/README.md telegram_bot/rustchain_query_bot.py telegram_bot/tests/test_bot_commands.py telegram_bot/tests/test_rustchain_client.py -> passed
  • python3 tools/bcos_spdx_check.py --base-ref origin/main -> OK

No blocking issues found in the updated PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) documentation Improvements or additions to documentation size/L PR: 201-500 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants