IMB: A New Approach to Bot Development
- Published on
- 6 min read
Table of Contents
- IMB: A New Approach to Bot Development
- Introduction
- Why IMB?
- How It Works?
- Technical Details
- Interactive Playground
- Current Status and Future Plans
- Try It!
- Contributing
- Conclusion
IMB: A New Approach to Bot Development
Introduction
There are many libraries available for creating Telegram bots - Grammy, Telegraf, python-telegram-bot, and others. But they all share the same problems: complex dependencies, huge node_modules folders, and platform lock-in. I created a new language to solve these problems - IMB (I Make Bot).
IMB is a simple, platform-agnostic bot creation language. Write once, use on any platform.
Why IMB?
Traditional Approach: Grammy/Telegraf
// node_modules: 180 MB
// package.json, tsconfig.json, .env...
import { Bot } from 'grammy'
const bot = new Bot('YOUR_BOT_TOKEN')
bot.command('start', (ctx) => ctx.reply('Hello!'))
bot.command('help', (ctx) => ctx.reply('Commands...'))
bot.start()
Problems:
- ๐ฆ Large size (node_modules 50-200 MB)
- ๐ Platform lock-in (Telegram โ Grammy, Discord โ Discord.js)
- ๐ ๏ธ Complex setup (dependencies, build tools)
- ๐ง Constant maintenance (breaking changes, updates)
IMB Approach
# bot.imb - only 2 KB!
on /start {
reply "Hello! ๐"
}
on /help {
reply "Available commands:\n/start\n/help"
}
Advantages:
- โก Zero dependencies
- ๐ฏ 2KB file size
- ๐ Platform agnostic (Telegram, Discord, Slack...)
- ๐ฆ Single binary (compiler + runtime + adapters)
- ๐ Learn in 5 minutes
How It Works?
Architecture
IMB consists of 3 parts:
- Compiler - Compiles .imb files to IR (Intermediate Representation)
- Runtime - Stateless event dispatch engine
- Adapters - Platform-specific integration (Telegram, Discord, etc.)
โโโโโโโโโโโโโโโ
โ bot.imb โ โ Bot code (2KB)
โโโโโโโโฌโโโโโโโ
โ compile
โ
โโโโโโโโโโโโโโโ
โ Bot IR โ โ Intermediate Representation
โโโโโโโโฌโโโโโโโ
โ runtime
โ
โโโโโโโโโโโโโโโ
โ Adapters โ โ Telegram, Discord, etc.
โโโโโโโโโโโโโโโ
Syntax
IMB syntax is very simple. Only 2 main constructs:
1. Event Handlers
on /start {
reply "Welcome!"
}
on /help {
reply "Help: /start, /help, /about"
}
2. Responses
on /about {
reply "This bot is built with IMB."
reply "Learn more: mcpeblocker.uz"
}
Running
# Create config
cat > imb-conf.ini << EOF
[telegram]
bot_token=YOUR_BOT_TOKEN
EOF
# Run the bot
imb run bot.imb --adapter telegram
That's it! No node_modules, no package.json, no build tools.
Technical Details
Written in Rust
IMB is written in Rust programming language. This provides:
- โก Speed and efficiency
- ๐ Memory safety
- ๐ฆ Single binary (dependencies statically compiled)
- ๐ฏ Cross-platform
Stateless Runtime
The runtime is stateless - meaning:
- Each event is processed independently
- Session state is managed by the adapter
- Easy scaling (horizontal scaling)
- Minimal memory footprint
Platform Adapters
Supporting multiple platforms through the adapter pattern:
pub trait Adapter {
async fn start(self: Box<Self>) -> Result<(), String>;
}
pub struct TelegramAdapter { /* ... */ }
pub struct DiscordAdapter { /* ... */ } // Coming soon
pub struct SlackAdapter { /* ... */ } // Coming soon
Interactive Playground
I created an interactive playground to test bot code in the browser:
๐ imb.mcpeblocker.uz/playground
Features:
- CodeMirror Editor - With syntax highlighting
- Real-time Testing - Test with real Telegram bots
- Template System - Hello World, FAQ Bot, Command List
- Live Console - Bot events displayed in real-time
- Download - Download bot as .imb file
How It Works?
The playground backend uses Node.js API routes to spawn the IMB binary:
// Next.js API Route
const imbProcess = spawn('imb', ['run', 'bot.imb', '--adapter', 'telegram'])
// Real-time logs via Server-Sent Events
imbProcess.stdout.on('data', (data) => {
// BOT_EVENT|RECEIVED|/start
// BOT_EVENT|REPLY|Hello!
clients.write(`data: ${JSON.stringify({ type: 'user', message })}\n\n`)
})
The user:
- Enters a Telegram bot token
- Writes IMB code or selects a template
- Clicks the "Start Bot" button
- Bot starts running
- Sends a message to the bot on Telegram
- Sees it in real-time in the playground console!
Current Status and Future Plans
โ Ready
- Rust compiler and runtime
- Telegram adapter (basic features)
- CLI tool (
imb run) - Interactive playground
- Basic Documentation
๐ง In Progress
-
Telegram adapter - More features:
- Inline buttons
- Media (photo, video, document)
- Callback queries
- Inline mode
- Payments API
-
Discord adapter - Coming soon
-
Slack adapter - Coming soon
-
State management - Variables and persistence
-
Conditionals - if/else constructs
-
Functions - For code reuse
๐ก Future Plans
-
More Syntax Features
# Variables var counter = 0 on /count { counter = counter + 1 reply "Count: " + counter } # Conditionals on message { if message.text == "hello" { reply "Hi there!" } } -
Plugin System - Custom adapters and extensions
-
VSCode Extension - Syntax highlighting and IntelliSense
-
Package Manager - Bot modules and libraries
-
Web Dashboard - Web interface for managing bots
Try It!
In the Playground
Try it now: imb.mcpeblocker.uz/playground
- Create a bot on Telegram via @BotFather
- Get the token
- Go to the playground
- Enter the token and write code
- Click "Start Bot"
- Send a message to your bot on Telegram!
Download
Download the IMB binary: imb.mcpeblocker.uz/download
# For Linux
wget https://imb.mcpeblocker.uz/imb
chmod +x imb
sudo mv imb /usr/local/bin/
# Create a bot
cat > mybot.imb << 'EOF'
on /start {
reply "Hello! I'm your bot ๐ค"
}
EOF
# Run it
imb run mybot.imb --adapter telegram
Contributing
IMB is still in development. If you know Rust or are interested - contribute!
How you can help:
-
Add features to Telegram adapter
- Inline buttons
- Media support
- Callback queries
-
Write new adapters
- Discord
- Slack
-
Add features to compiler
- Variables
- Conditionals
- Functions
-
Improve documentation
-
Find and fix bugs
If you're interested, contact me - I'll give you access to the private GitHub repo.
Contact:
- Website: mcpeblocker.uz
- Telegram: @mcpeblocker
Conclusion
IMB is a new approach to bot development. Zero dependencies, simple syntax, and platform agnostic. Still in early stages, but the future looks bright.
Advantages:
- โก Fast and efficient
- ๐ฆ Very small (2KB bot code, 9MB binary)
- ๐ Platform agnostic
- ๐ฏ Easy to learn
- ๐ Fast development
Disadvantages:
- ๐ง Still few features
- ๐ Limited documentation
- ๐ง Active development (breaking changes possible)
But the core idea is proven. For simple bots, this is an ideal solution.
Try it out and send me your feedback!
Useful links:
- ๐ฎ Playground: imb.mcpeblocker.uz/playground
- ๐พ Download: imb.mcpeblocker.uz/download
- ๐ Docs: imb.mcpeblocker.uz/docs
- ๐จโ๐ป Author: mcpeblocker.uz
Btw, IMB stands for I Make Bot :)
January 2025 โข Alisher Ortiqov