Orientação gerada a partir de informações públicas. Apenas para referência.
Televerse é um pacote Dart que simplifica a criação de bots eficientes do Telegram usando a versão mais recente da API do Telegram Bot (versão 9.5). Projetado para desenvolvedores que buscam integração perfeita com o Telegram, oferece uma interface limpa e intuitiva para lidar com mensagens, comandos e interações do bot em múltiplas plataformas. Com suporte para Android, iOS, macOS, Windows e Linux, o Televerse permite o desenvolvimento de bots multiplataforma sem comprometer desempenho ou funcionalidade. Sua arquitetura leve garante tempos de resposta rápidos e operação confiável em ambientes de produção.
Casos de uso
Construindo bots interativos do Telegram
Criando ferramentas de automação baseadas em chat
Desenvolvendo aplicativos de mensagens em tempo real
Integração com serviços externos por meio do Telegram
Suporte à implantação de bots multiplataforma
Principais recursos
Suporta a API de Bot do Telegram 9.5
Compatibilidade multiplataforma
Leve e de alto desempenho
API do Dart fácil de usar
Tratamento de comando embutido
Processamento de mensagens em tempo real
Indicado para
Desenvolvedores Dart construindo bots do Telegram
Equipes que precisam de soluções de bot multiplataforma
Projetos que exigem integração em tempo real com o Telegram
Startups prototipando chatbots rapidamente
Desenvolvedores focados em desempenho e escalabilidade
Considerações
Requer conhecimento de Dart
Dependente das atualizações da API do Telegram Bot
Limitado a casos de uso específicos do Telegram
Pode ser necessário tratamento adicional de erros em fluxos de trabalho complexos
Mais adequado para bots com fluxos de mensagens estruturados
README original
Snapshot do README original do repositório-fonte vinculado. Consulte o repositório para o conteúdo mais recente.
televerse
🤖 Bot API version: Bot API 10.2 (July 14, 2026)
Televerse is a powerful, easy-to-use, and highly customizable Telegram bot framework built with Dart programming language. It provides a complete and well-structured API that enables developers to create and deploy complex Telegram bots with ease. Televerse provides a total of 0 dynamic types on its public interface, making it easy for developers to write strictly typed code with full generic support.
💻 Getting Started
Creating a bot with Televerse is very easy! First, you need to import the Televerse package:
👨🏻💻 Installation
Add this to your package's pubspec.yaml file:
dependencies:televerse:<latest>
Now in your Dart code, you can import the Televerse package:
import'package:televerse/televerse.dart';
After importing the package, you can create a new bot instance by providing your bot token:
Bot bot = Bot('YOUR_BOT_TOKEN');
Now, you can start listening for updates such as messages, commands, etc. To start polling updates from Telegram servers, simply call:
await bot.start();
That's it! Your bot is now ready to receive updates from Telegram.
[!NOTE]
Remember to await the bot.start() call! This call initializes the bot and fetches details like its username. Starting the bot without awaiting could lead to unexpected behavior if initialization fails.
If you want to handle a specific command, such as the /start command, you can use the bot.command method. For example:
And that's all you need to get started with Televerse!
📚 Documentation
Televerse has a powerful API that is much simpler and easier to use. You can now use the bot instance to access the powerful Televerse methods and properties, and if you want to access the Telegram Bot API methods, you can use the bot.api getter. Simple, and clean.
Now, when you're inside a callback function, you can use the Context parameter which also provides you with the api property.
For example, if you want to send a message to a specific chat you can do it like this:
bot.api.sendMessage(ChatID(123456), "Hello, World!");
// or with the context
ctx.api.sendMessage(ChatID(123456), "Hello, World!");
🔊 Listening for Updates
Televerse offers a set of custom methods to simplify your development process. Some of these methods include:
bot.command to listen for commands
bot.on to listen for specific filters
bot.hears to listen for text patterns
Let's see an example:
bot.command("hello", (ctx) async {
await ctx.reply("Hello World 👋");
});
Similarly, you have access to many listener methods including bot.hears, bot.on, bot.callbackQuery etc to listen to specific events.
🎯 Revolutionary Filter System
Televerse now features a powerful filter system with 82 built-in filters that can be combined using logical operators!
// Simple filters
bot.on(bot.filters.photo, (ctx) async {
await ctx.reply('Nice photo! 📸');
});
bot.on(bot.filters.cmd('start'), (ctx) async {
await ctx.reply('Welcome to the bot! 🚀');
});
// Combinable filters with logical operators
bot.on(
bot.filters.photo + bot.filters.privateChat, // OR operation
(ctx) async {
await ctx.reply('Photo in private chat!');
},
);
bot.on(
bot.filters.text * bot.filters.groupChat, // AND operation
(ctx) async {
await ctx.reply('Text message in group!');
},
);
bot.on(
bot.filters.anyMessage - bot.filters.command, // Any message but NOT commands
(ctx) async {
await ctx.reply('Non-command message received!');
},
);
You can also create custom filters:
bot.filter(
(ctx) => (ctx.text?.length ?? 0) > 100,
(ctx) async {
await ctx.reply('That was a long message!');
},
);
🔑 Key Features
1. 🎯 Strictly Typed with Generics
Televerse uses 0 dynamic types on the public interface and supports full generic typing, ensuring type safety and reliability throughout your bot development process.
// Custom context with full type safetyclassMyContextextendsContext{
MyContext(super.update, super.api, super.me);
Stringget userName => from?.firstName ?? 'Unknown';
boolget isVip => get<bool>('vip') ?? false;
}
final bot = Bot('token', contextFactory: MyContext.new);
bot.command('profile', (MyContext ctx) async {
await ctx.reply('Hello ${ctx.userName}! VIP: ${ctx.isVip}');
});
2. 🏠 Local Bot API Server Support
Host your own Bot API server and listen to updates effortlessly with Televerse. Simply use the Bot.local constructor to configure your bot with a custom base URL.
/// Creates the bot instance with local Bot API server.finalBot bot = Bot.local(
"YOUR_BOT_TOKEN",
"http://localhost:8081",
);
3. 🌐 Serverless Setup Compatibility
Whether you're using Cloud Functions or Lambda Functions, Televerse has you covered. Utilize Bot.handleUpdate to handle updates manually in your serverless environment.
// Create bot instance, and setup listeners// ...final json = jsonDecode(event.body);
final update = Update.fromJson(json);
bot.handleUpdate(update);
4. 🔧 Custom HTTP Client Support
Say goodbye to uncertainty with Televerse's flexible HTTP client system. You can now pass your own HTTP client with custom interceptors for complete control over network requests.
// Admin-only commands in private chat
bot.on(
bot.filters.cmd('admin') * bot.filters.privateChat * bot.filters.user(adminId),
adminHandler,
);
// Media in groups but not from bots
bot.on(
bot.filters.media * bot.filters.groupChat - bot.filters.bot,
groupMediaHandler,
);
8. 🚀 Latest Telegram Bot API Support
Stay up-to-date with the latest version of the Telegram Bot API, supported by Televerse. That's a promise.
9. 🛡️ Enhanced Error Handling
Handle errors gracefully with comprehensive error handling system:
import'dart:developer';
// Global error handler
bot.onError((err) {
log(
"Something went wrong: $err",
error: err.error,
stackTrace: err.stackTrace,
);
});
// Error boundaries for specific middleware
bot.errorBoundary(
(err, next) async {
await err.ctx?.reply('Something went wrong, but we handled it!');
awaitnext(); // Continue processing
},
[
// Protected middleware
(ctx, next) async {
// This might throw an errorawaitriskyOperation();
awaitnext();
},
],
);
10. 💬 Advanced Conversation API
Engage users in complex conversations with the powerful Conversation Plugin:
// Install the conversation plugin
bot.plugin(ConversationPlugin<Context>());
// Define a conversation functionFuture<void> askUserInfo(Conversation<Context> conversation, Context ctx) async {
try {
await ctx.reply("What's your name?");
// Wait for text message with timeoutfinal nameCtx = await conversation.waitFor(
bot.filters.text.matches,
timeout: Duration(minutes: 2),
);
await nameCtx.reply("Nice to meet you, ${nameCtx.text}!");
await nameCtx.reply("How old are you?");
// Wait for a number with validationfinal ageCtx = await conversation.waitUntil(
(ctx) => int.tryParse(ctx.text ?? '') != null,
timeout: Duration(minutes: 1),
otherwise: (ctx) async {
await ctx.reply("Please send a valid number.");
},
);
final age = int.parse(ageCtx.text!);
await ageCtx.reply("Great! You are $age years old.");
} onConversationTimeoutException {
await ctx.reply("Sorry, you took too long to respond.");
}
}
// Register the conversation
bot.use(createConversation('userInfo', askUserInfo));
// Start the conversation
bot.command('info', (ctx) async {
await ctx.conversation.enter('userInfo');
});
11. 📲 InlineMenu and KeyboardMenu Utility Classes
Effortlessly build Interactive Menus with built-in handler registration:
// Define handler methodsFuture<void> accountHandler(Context ctx) async {
await ctx.replyWithPhoto(InputFile.fromFile(File("account.png")));
await ctx.reply("Here's your account details...");
}
// Define menu optionsfinal menu = KeyboardMenu()
.text("Account", accountHandler)
.text("Referral", referralHandler)
.text("Settings", settingsHandler)
.resized();
// Attach menu to bot
bot.attachMenu(menu);
// Use menu in commands
bot.command('start', (ctx) async {
await ctx.reply(
"Hello, I am ${ctx.me.username}. Let's start.",
replyMarkup: menu,
);
});
12. 🔍 Inline Query Result Builder
Efficiently build inline query results with the enhanced InlineQueryResultBuilder, supporting all inline query result types.
13. 🔌 Revolutionary Plugin System
Televerse now features a comprehensive plugin architecture with three built-in plugins:
classRateLimitPlugin<CTXextendsContext> extendsMiddlewarePlugin<CTX> {
@overrideStringget name => 'rate-limit';
@overrideMiddleware<CTX> get middleware => (ctx, next) async {
// Rate limiting logicif (awaitisRateLimited(ctx.from?.id)) {
await ctx.reply('Too many requests!');
return;
}
awaitnext();
};
@overrideList<String> get dependencies => [];
@overrideString? get description => 'Rate limiter plugin';
@overridevoiduninstall(Bot<CTX> bot) => bot.removeNamed(name);
@overrideStringget version => 'v1.0.0';
}
bot.plugin(RateLimitPlugin<Context>());
14. 🔧 Enhanced Middleware System
The new middleware system provides powerful composition capabilities:
// Function-based middleware
bot.use((ctx, next) async {
print('📥 Processing update ${ctx.update.updateId}');
final start = DateTime.now();
awaitnext();
final duration = DateTime.now().difference(start);
print('✅ Processed in ${duration.inMilliseconds}ms');
});
// Conditional middleware
bot.when(
(ctx) => ctx.isPrivateChat,
(ctx, next) async {
await ctx.reply('This is a private chat!');
awaitnext();
},
);
// Forked middleware (runs concurrently)
bot.fork((ctx, next) async {
// This runs in parallel with other middlewareawaitlogToDatabase(ctx.update);
});
// Lazy middleware (created on demand)
bot.lazy((ctx) {
return (ctx, next) async {
// Middleware created based on contextif (ctx.isGroupChat) {
awaitgroupSpecificMiddleware(ctx, next);
} else {
awaitnext();
}
};
});
15. 🌐 Built-in Webhook Server
Start a webhook bot with just one method call:
final bot = Bot<Context>('YOUR_BOT_TOKEN');
bot.command('start', (ctx) async {
await ctx.reply('Hello from webhook bot! 🚀');
});
// This is all you need for a webhook bot!await bot.startWebhook(
webhookUrl: 'https://your-domain.com/webhook',
port: 8080,
);
If you find Televerse helpful, please consider shooting a star on our Github repository. This helps us to know that our work is appreciated and motivates us to continue improving Televerse.
🤝 Join the Discussion
We have an active Telegram group where you can discuss Televerse and get help from other users and developers.
Thank you ❤️
Televerse is a powerful and easy-to-use library for building Telegram bots in Dart. With its revolutionary filter system, advanced plugin architecture, and comprehensive type safety, you can write clean, maintainable code that scales from simple bots to enterprise applications. The new middleware system, conversation API, and built-in webhook server make Televerse the most advanced Telegram bot framework in the Dart ecosystem!