teledart 0.0.7 copy "teledart: ^0.0.7" to clipboard
teledart: ^0.0.7 copied to clipboard

outdatedDart 1 only

Telegram bot api framework in Dart

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.

TeleDart

Bot API Version Dart Version License: GPL v3

Features #

Usage #

A simple usage example:

//import 'dart:io' as io;

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();

  // You can listen to messages like its
  teledart.onMessage(entityType: 'bot_command', keyword: 'start')
      .listen((message) {
        teledart.telegram.sendMessage(message.from.id, 'Hello TeleDart!');
      });

  // Or using short cuts
  teledart.onCommand('short').listen(((message) =>
      teledart.replyMessage(message, 'This works too!')));

  // You can even filter streams even more diverse with stream processing methods
  // See: https://www.dartlang.org/tutorials/language/streams#methods-that-modify-a-stream
  teledart.onMessage(keyword: 'dart')
      .where((Message message) =>
          message.text.contains('telegram'))
      .listen((message) {
    teledart.replyPhoto(
            message,
//            new io.File('example/dart_bird_catchs_telegram.png'),
            '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
  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.

277
likes
0
pub points
89%
popularity

Publisher

verified publisherd1n0.xyz

Telegram bot api framework in Dart

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

dartson, http

More

Packages that depend on teledart