televerse 1.2.2 televerse: ^1.2.2 copied to clipboard
Televerse is a Telegram Bot API Framework written completely in Dart. You can use this framework to create your own Telegram Bots, efficiently and easily.
Televerse #
Televerse is simple & efficient way to create Telegram bots with Dart.
Bot API version: Bot API 6.4
👨🏻💻 Installation #
Add this to your package's pubspec.yaml file:
dependencies:
televerse: ^1.1.0
📖 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 #
At the same time 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 in the example file.
📝 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.