A Telegram bot and REST API for executing Cyrus programming language code using the latest binary from GitHub Actions artifacts.
- Telegram Bot - Executes code in @cyrus_lang group
- REST API - HTTP API for web/mobile apps (see API.md)
- Shared Library - Common execution logic
- Download latest Cyrus binary from GitHub Actions artifacts (no GitHub token required!)
- Execute Cyrus code through Telegram
- Telegram Bot: Only works in @cyrus_lang group
- Admin Control: Enable/disable bot and set topic restrictions via inline keyboard buttons
- Smart Mentions: Only responds when bot is mentioned with
@cyrus_playground_bot - Clean Output: Uses expandable quote blocks for long outputs (no group spam)
- API: Available for web/mobile apps (optional, see API.md)
- Supports topic/forum groups with per-topic control via button panel
- Automatic updates: Checks for new Cyrus builds every 12 hours
- Smart caching: Only downloads if a new version is available
- Fast execution: Async processing with instant message updates
-
Install Rust (if not already installed):
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
-
Clone and build:
cd cyrus-playground-bot cargo build --release -
Configure environment variables:
cp .env.example .env
Edit
.envand add:CYRUS_BOT_TOKEN: Your Telegram bot token from @BotFatherPORT: API server port (default: 3000)RUST_LOG: Log level (info, debug, error)
-
Bot Configuration
- Admin ID: Set in source code (src/main.rs)
- Group: @cyrus_lang
- Only admin can control bot via private chat
source .env
cargo run --bin cyrus-bot --releaseOr:
./target/release/cyrus-botsource .env
cargo run --bin cyrus-api --releaseOr:
./target/release/cyrus-apiTerminal 1:
source .env
cargo run --bin cyrus-bot --releaseTerminal 2:
source .env
cargo run --bin cyrus-api --releaseAdmin (ID: 7474145303) can control the bot via inline keyboard buttons in private chat.
Send /start or /menu to the bot in private chat.
- 🟢 Enable Bot - Turn bot on
- 🔴 Disable Bot - Turn bot off
- 📋 Manage Topics - View and toggle individual topics
- 🌐 Enable All Topics - Allow all topics at once
- Click on any topic to toggle it on/off
- ✅ = Topic enabled
- ❌ = Topic disabled
- Real-time status updates
Mention the bot with your code:
@cyrus_playground_bot
import std::libc{printf};
pub fn main() {
printf("Hello, Cyrus!\n");
}
The bot will:
- Execute your code instantly
- Reply with a collapsed quote for long outputs
- Show execution time and status
- Update the message in real-time
- Short output (<200 chars): Regular code block
- Medium output (200-3500 chars): Expandable quote block
- Long output (>3500 chars): Truncated expandable quote block
- Status: Shows ✅ Success or ❌ Failed with execution time
Mention the bot with your Cyrus code in @cyrus_lang group:
@cyrus_playground_bot
import std::libc{printf};
pub fn main() {
printf("Hello, Cyrus!\n");
}
Bot will execute and show results with:
- ✅ Success or ❌ Failed status
- Execution time
- Expandable quotes for long outputs
- Real-time updates
See API.md for complete API documentation.
Quick example:
curl -X POST http://localhost:3000/api/execute \
-H "Content-Type: application/json" \
-d '{"code": "import std::libc{printf};\n\npub fn main() {\n printf(\"Hello!\\n\");\n}"}'When you send code, the response is:
✅ Success (0.23s)
Hello, Cyrus!
All output is displayed in clean code blocks.
The bot only responds in the @cyrus_lang group (or supergroup).
To use:
- Add the bot to @cyrus_lang group
- Make sure the bot has permission to read messages
- Group admins use
/settopicin each topic to enable the bot - Works with topics (forum-style groups)
- On Startup: Automatically downloads the latest Cyrus binary + stdlib
- Update Checks: Every 12 hours, checks GitHub for new successful builds
- Smart Updates: Only downloads if run_id has changed
- Execution: Uses nightly.link service to access public artifacts without authentication
- Command: Runs
cyrus run <file>(stdlib is auto-detected from artifact)
- nightly.link (no token): ~60 requests/hour per IP
- Update frequency: Every 12 hours (well within limits)
- Download size: Typically 5-50 MB per artifact
- No issues: Smart caching means downloads only when new version exists
- Rust 1.70+
- Telegram Bot Token (for bot)
- Internet connection
- The bot executes code in temporary files
- Telegram Bot: Only responds in @cyrus_lang group for security
- API: Open to all (add authentication/rate limiting for production)
- Consider implementing additional sandboxing for production use
- Limit execution time and resource usage
For production API deployment:
- Use reverse proxy (Nginx/Caddy)
- Add rate limiting
- Implement proper sandboxing
- Add monitoring and metrics
- Use HTTPS
See API.md for details.
MIT