televerse 1.3.0 televerse: ^1.3.0 copied to clipboard
Televerse lets you create your own efficient Telegram bots with ease in Dart. Supports latest Telegram Bot API - 6.5!
Televerse #
Televerse is simple & efficient way to create Telegram bots with Dart.
🤖 Bot API version: Bot API 6.5
👨🏻💻 Installation #
Add this to your package's pubspec.yaml file:
dependencies:
televerse: <latest>
📖 Usage #
With Televerse you can create a simple bot in just a few lines of code:
import 'package:televerse/televerse.dart';
Bot bot = Bot('YOUR_BOT_TOKEN');
Now with the bot instance you can start listening for updates:
bot.command('start', (ctx) {
ctx.reply('Hello, World!');
});
📚 Documentation #
📖 Televerse Wiki #
We have a dedicated documentation on GitHub Wiki on this repo. Check it our here: Televerse Wiki.
✨ In simple words #
You can access the whole Telegram Bot API methods with the bot
instance. Or if you're inside a MessageContext
you can access the same with ctx.api
For example, if you want to send a message to a specific chat you can do it like this:
bot.sendMessage(ChatID(123456), "Hello, World!");
// or with the context
ctx.api.sendMessage(ChatID(123456), "Hello, World!");
👽 Advanced Usage #
We also provide a set of custom methods to make your life easier. Some of them are:
bot.command
to listen for commandsbot.chatType
andbot.chatTypes
to listen for specific chat typesbot.text
to listen for text messages that contains a specific text
And even advanced methods like
bot.filter
to create your own filters and listen for messages that match thembot.hear
to listen for messages that match a RegExp
Filter and hear methods are very powerful and can be used to create your own custom filters.
For example, if you want to listen for messages that contains a photo which has more than 1MB of size, you can do it like this:
bot.filter((ctx) {
return (ctx.message.photo?.last.fileSize ?? 0) > 1000000;
}, (ctx) {
ctx.reply('Wow, that\'s a big photo!');
});
Note: we're still working on improving the documentation, so you can check the example file for more information.
🔐 Example #
You can find a simple example of a bot that uses Televerse in the example file.
👽 Examples Repo #
But, where's the fun in that? So we've created an entire repository with examples of bots built with Televerse. Check it out here: Televerse Examples.
This repository includes examples of bots such as simple letter counting bot to referral bot, and many more on the way. Moreover, we've detailed the code and explained how it works, so you can learn how to build your own bots with Televerse.
📝 Note #
We're still at the early stages of the project, so we're working on improving the documentation and adding more features.
👫 Contributing #
If you want to contribute to the project, you can do it by opening a pull request or by opening an issue.
Jump into our Telegram Group to discuss about the project.