Crypto Telegram Price Bot πͺ
A Rust-based Telegram bot that automatically posts cryptocurrency price updates to a Telegram channel every hour using GitHub Actions. Currently tracks Bitcoin and Solana, with easy extensibility for additional cryptocurrencies.
Features
- π Automated hourly updates via GitHub Actions
- π° Multi-coin support - Bitcoin, Solana, and easily extensible to other coins
- π Real-time prices from CoinPaprika API
- π± Clean formatted messages with emoji and HTML formatting
- π Simple deployment - no server required
- π Secure - credentials stored in GitHub Secrets
- β‘ Fast and efficient - runs once per execution, exits cleanly
How It Works
- GitHub Actions triggers the bot every hour via cron schedule
- Bot fetches current prices for all configured cryptocurrencies from CoinPaprika API
- Formats a nice message with prices for each coin
- Sends the message to your configured Telegram channel
- Exits (no continuous running process needed)
Setup Instructions
1. Create a Telegram Bot
- Open Telegram and search for @BotFather
- Send
/newbot command
- Follow the prompts to choose a name and username
- Copy the bot token (you'll need this later)
2. Create a Telegram Channel
- Create a new channel in Telegram
- Add your bot as an administrator to the channel
- Get your channel ID:
- For public channels: use
@channelname format
- For private channels: use a bot like @getidsbot to get the numeric ID (e.g.,
-1001234567890)
3. Fork/Clone This Repository
git clone <your-repo-url>
cd cryptobot
4. Configure GitHub Secrets
- Go to your GitHub repository
- Navigate to Settings β Secrets and variables β Actions
- Add the following secrets:
TELOXIDE_TOKEN: Your bot token from BotFather
TELEGRAM_CHANNEL_ID: Your channel ID (e.g., @mychannel or -1001234567890)
5. Enable GitHub Actions
- Go to the Actions tab in your repository
- Enable workflows if prompted
- The bot will now run automatically every hour
6. Test Locally (Optional)
- Create a
.env file in the project root:
TELOXIDE_TOKEN=your_bot_token_here
TELEGRAM_CHANNEL_ID=@your_channel_here
- Build and run:
cargo build --release
cargo run --release
- Check your Telegram channel for the message
Project Structure
cryptobot/
βββ Cargo.toml # Project dependencies
βββ .env # Local environment variables (gitignored)
βββ .gitignore # Git ignore rules
βββ src/
β βββ main.rs # Main bot logic (coin configuration on line 105)
βββ .github/
β βββ workflows/
β βββ hourly-update.yml # GitHub Actions workflow
βββ README.md # This file
Configuration
Environment Variables
- TELOXIDE_TOKEN (required): Your Telegram bot token
- TELEGRAM_CHANNEL_ID (required): Target channel ID
Modify Update Frequency
Edit .github/workflows/hourly-update.yml:
on:
schedule:
# Current: Every hour at minute 0
- cron: '0 * * * *'
# Examples:
# Every 30 minutes: '*/30 * * * *'
# Every 6 hours: '0 */6 * * *'
# Daily at noon: '0 12 * * *'
Troubleshooting
Bot Not Sending Messages
-
Check GitHub Actions logs:
- Go to Actions tab β Select latest workflow run
- Review the logs for error messages
-
Verify bot permissions:
- Ensure bot is an administrator in the channel
- Check that bot can post messages
-
Validate credentials:
- Double-check
TELOXIDE_TOKEN in GitHub Secrets
- Verify
TELEGRAM_CHANNEL_ID format
-
Test locally:
- Run the bot locally with
.env file to isolate issues
Common Errors
- "TELOXIDE_TOKEN not set": Add the token to GitHub Secrets
- "Failed to send message": Check bot permissions in channel
- "Invalid channel ID": Use correct format (
@username or numeric ID)
- API rate limiting: CoinPaprika free tier has rate limits; don't run too frequently
Dependencies
- teloxide (0.14): Telegram bot framework
- reqwest (0.11): HTTP client for API calls
- tokio (1.x): Async runtime
- serde/serde_json: JSON serialization
- anyhow: Error handling
- dotenv: Environment variable loading
- rusty-money (0.5): Currency formatting
API Information
CoinPaprika API
- Endpoint:
https://api.coinpaprika.com/v1/tickers/{coin-id}
- Rate Limit: 10-30 calls/minute (free tier)
- No authentication required
- Documentation: https://coinpaprika.com/api
Currently Tracked Coins
- Bitcoin (BTC) - ID:
btc-bitcoin
- Solana (SOL) - ID:
sol-solana
Adding More Coins
To add support for additional cryptocurrencies:
- Find the coin ID from CoinPaprika (format:
{symbol}-{name})
- Open
src/main.rs
- Add the coin ID to the
coins array on line 105:
let coins = ["btc-bitcoin", "sol-solana", "eth-ethereum"]; // Add your coin here
- Commit and push your changes - the bot will automatically track the new coin!
Future Enhancements
Potential improvements:
- Support multiple cryptocurrencies β
- Price change percentage (24h)
- Price alerts for thresholds
- Historical price charts
- Price trend indicators
- Store price history
License
MIT License - Feel free to use and modify!
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
Disclaimer
This bot is for informational purposes only. Cryptocurrency prices are volatile. Do not make financial decisions based solely on this bot's data.