Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/DinoLeung/TeleDart
A Dart library interfacing with the latest Telegram Bot API.
https://github.com/DinoLeung/TeleDart
dart telegram telegram-bot telegram-bot-api telegram-bot-sdk
Last synced: 3 months ago
JSON representation
A Dart library interfacing with the latest Telegram Bot API.
- Host: GitHub
- URL: https://github.com/DinoLeung/TeleDart
- Owner: DinoLeung
- License: gpl-3.0
- Created: 2018-05-04T04:19:25.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-04-06T06:30:11.000Z (11 months ago)
- Last Synced: 2024-11-14T09:02:32.051Z (3 months ago)
- Topics: dart, telegram, telegram-bot, telegram-bot-api, telegram-bot-sdk
- Language: Dart
- Homepage: https://pub.dev/packages/teledart
- Size: 1.21 MB
- Stars: 314
- Watchers: 16
- Forks: 70
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-telegram - TeleDart - A Dart library interfacing with the latest Telegram Bot API. (Bots / Bot Libs)
- awesome-telegram - Dart: TeleDart
- awesome-telegram - Dart: TeleDart
README
# TeleDart
A clean implementation of [Telegram bot API](https://core.telegram.org/bots/api) allows you to create your own easily.

[](https://core.telegram.org/bots/api)
[](https://dart.dev)
[](https://www.gnu.org/licenses/gpl-3.0)[](https://github.com/DinoLeung/TeleDart)
## Creating a Telegram bot
In order to create a Telegram bot, you need to talk to [@BotFather](https://t.me/botfather) generating a bot token. Simply follow the [instructions](https://core.telegram.org/bots#6-botfather).
## Usage
Initialising the bot:
```dart
import 'package:teledart/teledart.dart';
import 'package:teledart/telegram.dart';void main() {
var BOT_TOKEN = 'YOUR_BOT_TOKEN_FROM_BOT_FATHER';
final username = (await Telegram(BOT_TOKEN).getMe()).username;
var teledart = TeleDart(BOT_TOKEN, Event(username!));teledart.start()
}
```A simple usage example:
```dart
teledart.onMessage(keyword: 'Fight for freedom')
.listen((message) => message.reply('Stand with Hong Kong'));
```Using bot commands:
```dart
// Long way
teledart.onMessage(entityType: 'bot_command', keyword: 'start')
.listen((message) => teledart.sendMessage(message.chat.id, 'Hello TeleDart!'));// Short way (recommended)
teledart.onCommand('glory')
.listen((message) => message.reply('to Ukraine!'));
```Modifying [Stream](https://www.dartlang.org/tutorials/language/streams#methods-that-modify-a-stream):
```dart
teledart
.onMessage(keyword: 'dart')
.where((message) => message.text?.contains('telegram') ?? false)
.listen((message) => message.replyPhoto(
// io.File('example/dash_paper_plane.png'),
'https://raw.githubusercontent.com/DinoLeung/TeleDart/master/example/dash_paper_plane.png',
caption: 'This is how the Dart Bird and Telegram are met'));
```[Inline mode](https://core.telegram.org/bots/api#inline-mode) example:
```dart
teledart.onInlineQuery().listen((inlineQuery) => inlineQuery.answer([
InlineQueryResultArticle(
id: 'ping',
title: 'ping',
inputMessageContent: InputTextMessageContent(
messageText: '*pong*', parseMode: 'MarkdownV2')),
InlineQueryResultArticle(
id: 'ding',
title: 'ding',
inputMessageContent: InputTextMessageContent(
messageText: '*_dong_*', parseMode: 'MarkdownV2')),
]));
```## Bugs and feature requests
Please file feature requests and bugs at the [issue tracker][tracker].
[tracker]: https://github.com/DinoLeung/TeleDart/issues