Telegem Documentation
Welcome to the comprehensive documentation for Telegem, a modern Ruby framework for building Telegram bots.
Table of Contents
Getting Started
- README - Main project README
- Getting Started - Installation and basic setup
- Core Concepts - Understanding Telegem architecture
Core Components
- Bot - Main bot class and configuration
- Context - Update context and response methods
- Handlers - Command, hears, and event handlers
- Middleware - Request processing pipeline
- Scenes - Multi-step conversation flows
- Sessions - Data persistence between updates
API & Types
- API - Telegram API client usage
- Types - Type-safe API response handling
- Keyboards - Inline and reply keyboard DSL
Advanced Features
- Plugins - Built-in and custom plugins
- Webhooks - Production webhook deployment
- Error Handling - Comprehensive error management
- Testing - Unit and integration testing
- Deployment - Production deployment guides
Examples & Guides
- Examples - Complete bot examples
- Troubleshooting - Common issues and solutions
- Contributing - Development guidelines
- Changelog - Version history and changes
Quick Start
Install Telegem:
gem install telegemCreate your first bot:
require 'telegem'
bot = Telegem.new(token: 'YOUR_BOT_TOKEN')
bot.command('start') do |ctx| ctx.reply('Hello, World!') end
bot.start_polling
3. **Explore features:**
- Add [handlers](handlers.md) for different message types
- Use [sessions](sessions.md) for data persistence
- Implement [scenes](scenes.md) for complex conversations
- Deploy with [webhooks](webhooks.md) for production
## Key Features
- **Async I/O**: Built on the Async gem for high performance
- **Type Safety**: Automatic type conversion for API responses
- **Session Management**: Built-in session stores (Memory, Redis)
- **Plugin System**: Extensible with custom plugins
- **Scene System**: Complex conversation flows
- **Middleware**: Request processing pipeline
- **Error Handling**: Comprehensive error recovery
- **Testing**: Full test suite with mocking support
## Architecture Overview
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │ Telegram API │◄──►│ API Client │◄──►│ Handlers │ └─────────────────┘ └─────────────────┘ └─────────────────┘ ▲ │ ┌─────────────────┐ │ Middleware │ └─────────────────┘ ▲ │ ┌─────────────────┐ │ Sessions │ └─────────────────┘
## Support
- **Documentation**: You're reading it!
- **Issues**: [GitHub Issues](https://github.com/telegem/telegem/issues)
- **Discussions**: [GitHub Discussions](https://github.com/telegem/telegem/discussions)
- **Examples**: Check the `examples/` directory
## Contributing
We welcome contributions! See our [contributing guide](contributing.md) for details.
## License
Telegem is released under the MIT License. See the main README for details.
---
**Happy bot building with Telegem! 🤖**
```ruby
gem 'telegem'
Basic Usage
require 'telegem'
bot = Telegem.new('YOUR_BOT_TOKEN')
bot.command('start') do |ctx|
ctx.reply("Hello, #{ctx.from.first_name}!")
end
bot.start_polling
Requirements
- Ruby 3.0+
- Telegram Bot Token from @BotFather
License
MIT License - see LICENSE file for details.
Contributing
See Contributing Guide for development setup and contribution guidelines.