Telegem Documentation

Welcome to the comprehensive documentation for Telegem, a modern Ruby framework for building Telegram bots.

Gem Version Join Telegram Group

Table of Contents

Getting Started

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

Examples & Guides

Quick Start

  1. Install Telegem:

    gem install telegem
    
  2. Create 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

License

MIT License - see LICENSE file for details.

Contributing

See Contributing Guide for development setup and contribution guidelines. /home/slick/telegem/docs/README.md