teledart 0.0.27 teledart: ^0.0.27 copied to clipboard
A Dart library interfacing with the latest Telegram Bot API.
TeleDart #
Telegram is a popular secured instant messenger. They have an open bot platform, this package is a Dart implementation of their bot API allowing you to create your own bot easily.
Features #
- Fully support Telegram Bot API 4.1
- Inline mode
- Telegram Payment Platform
- Telegram Passport
- Gaming Platform
- Dart 2 ready!!!
Usage #
A simple usage example:
import 'package:teledart/teledart.dart';
import 'package:teledart/telegram.dart';
import 'package:teledart/model.dart';
void main() {
TeleDart teledart = new TeleDart(new Telegram('YOUR_BOT_TOKEN'), new Event());
teledart.startFetching();
teledart
.onCommand('hello')
.listen(((message) => teledart.replyMessage(message, 'world')));
}
Modifying Stream:
teledart
.onMessage(keyword: 'dart')
.where((Message message) => message.text.contains('telegram'))
.listen((message) {
teledart.replyPhoto(
message,
'https://raw.githubusercontent.com/DinoLeung/TeleDart/master/example/dart_bird_catchs_telegram.png',
caption: 'This is how the Dart Bird and Telegram are met');
});
Inline mode example:
teledart.onInlineQuery().listen((inlineQuery) {
List<InlineQueryResult> results = [
new InlineQueryResultArticle()
..id = 'ping'
..title = 'ping'
..input_message_content = (new InputTextMessageContent()
..message_text = '*pong*'
..parse_mode = 'markdown'),
new InlineQueryResultArticle()
..id = 'ding'
..title = 'ding'
..input_message_content = (new InputTextMessageContent()
..message_text = '_dong_'
..parse_mode = 'markdown')
];
teledart.answerInlineQuery(inlineQuery, results);
});
Bugs and feature requests #
Please file feature requests and bugs at the issue tracker.