VOOZH about

URL: https://dev.to/zendrx/from-ruby-to-crystal-why-i-ported-telegem-to-telecr-29m

⇱ From Ruby to Crystal: Why I ported telegem to telecr - DEV Community


After my work on telegem (a Ruby gem for creating DSLs), I began to notice the stark differences between interpreted and compiled languages.

Ruby is fast, but for high-concurrency needs like Telegram bots, I wanted to see what Crystal could do. To my surprise, porting the logic worked beautifully. Today, I’m excited to announce telecr.

What is Telecr?

Telecr is a fast, fiber-based library for creating Telegram bots in Crystal. Think of it as telegem with superpowers.

Key Features

  • Blazing Fast: Leverages Crystal's performance and fiber-based concurrency.
  • Type Safe: Catch errors at compile time before they hit production.
  • Disk Backup: Reliable data handling.
  • Clean DSL: Designed for a great developer experience.

Quick Look at the DSL

 bot.command("start") do ctx 
 ctx.reply("welcome")
end

Join the Project

I'm officially opening this up for contributions and improvements! You can find the source code and documentation here:

πŸ‘ GitHub logo
slick-lab / telecr

A modern fiber based crystal framework for create telegram bots

Telecr

Telegram bot framework for Crystal. Inspired by telegem (Ruby).

πŸ‘ Pipeline Status
πŸ‘ Coverage
πŸ‘ Latest Release
πŸ‘ Crystal
πŸ‘ License: MIT

Documentation

Full API documentation is available at: https://telecr.gitlab.io

Installation

Add to your shard.yml:

dependencies:
 telecr:
 github: slick-lab/telecr
 version: ~> 1.0.0

Then run:

shards install

Quick Start

require "telecr"

bot = Telecr.new("YOUR_BOT_TOKEN")

bot.command("start") do |ctx|
 ctx.reply("Welcome to Telecr!")
end

bot.start_polling

Features

  • Full Telegram Bot API support
  • Polling and webhook modes
  • Middleware system (session, rate limiting, file upload)
  • Reply and inline keyboards
  • Type-safe context objects
  • Session management with disk backup
  • File upload to shrine storage

Usage

Basic Bot

bot = Telecr.new("TOKEN")

bot.command("start") do |ctx|
 ctx.reply("Hello! I'm a Telecr bot.")
end

bot.hears(/hi/i) do |ctx|
 ctx.reply("Hi there!")
end

bot.start_polling

…

I'm curiousβ€”have any of you moved a project from Ruby to Crystal? What was your biggest "aha!" moment during the port?