teledart 0.0.18

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 62

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 '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.

0.0.18

  • Update readme

0.0.17

  • Added Bot API 4.1 support
  • Update dependencies

0.0.16

  • Hot fix model json annotation file

0.0.15

  • Hot fix inline_keyboard variable in InlineKeyboardMarkup

0.0.14

  • Add shortcuts

0.0.13

  • Supports API 4.0

0.0.12

  • Depends on json_serializable/json_annotation handling json objects
  • Fixes typos in model.dart

0.0.11

  • Supports regular expression in onMessage()

0.0.10

  • Fixes pubspec.ymal SDK constraint to support Dart 2 release
  • Edit README.md Dart Version shield to build version

0.0.9

  • Bug fixes
  • Edit example in README.md

0.0.8

  • Bug fixes
  • Edit example

0.0.7

  • Dart2 ready!
  • Add short-cut for inline query
  • Rename ChosenInlineQuery into ChosenInlineResult and associated objects
  • Add missing InlineQueryResultVoice to model
  • Bug fixes

0.0.6

  • Edit README.md

0.0.5

  • Add onMessage short-cuts
  • Add sendMessage short-cuts
  • Add missing ShippingQuery to Update

0.0.4

  • More editing on README.md

0.0.3

  • Edited README.md

0.0.2

  • First release

0.0.1

  • Initial version, created by Stagehand

example/TeleDart_example.dart

//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 this
  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);
  });
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  teledart: ^0.0.18

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:teledart/teledart.dart';
  
Version Uploaded Documentation Archive
0.0.18 Oct 18, 2018 Go to the documentation of teledart 0.0.18 Download teledart 0.0.18 archive
0.0.17 Oct 18, 2018 Go to the documentation of teledart 0.0.17 Download teledart 0.0.17 archive
0.0.16 Sep 19, 2018 Go to the documentation of teledart 0.0.16 Download teledart 0.0.16 archive
0.0.15 Sep 19, 2018 Go to the documentation of teledart 0.0.15 Download teledart 0.0.15 archive
0.0.14 Sep 5, 2018 Go to the documentation of teledart 0.0.14 Download teledart 0.0.14 archive
0.0.13 Aug 19, 2018 Go to the documentation of teledart 0.0.13 Download teledart 0.0.13 archive
0.0.12 Aug 14, 2018 Go to the documentation of teledart 0.0.12 Download teledart 0.0.12 archive
0.0.11 Jul 31, 2018 Go to the documentation of teledart 0.0.11 Download teledart 0.0.11 archive
0.0.10 Jul 21, 2018 Go to the documentation of teledart 0.0.10 Download teledart 0.0.10 archive
0.0.9 Jun 22, 2018 Go to the documentation of teledart 0.0.9 Download teledart 0.0.9 archive

All 17 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
37
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
62
Learn more about scoring.

We analyzed this package on Oct 18, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.4

Platforms

Detected platforms: Flutter, other

Primary library: package:teledart/teledart.dart with components: io.

Health suggestions

Format lib/src/telegram/model.dart.

Run dartfmt to format lib/src/telegram/model.dart.

Maintenance suggestions

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Package is pre-v0.1 release. (-10 points)

While there is nothing inherently wrong with versions of 0.0.*, it usually means that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
http ^0.12.0 0.12.0
json_annotation ^1.2.0 1.2.0
Transitive dependencies
async 2.0.8
charcode 1.1.2
collection 1.14.11
http_parser 3.1.3
meta 1.1.6
path 1.6.2
source_span 1.4.1
string_scanner 1.0.4
typed_data 1.1.6
Dev dependencies
build_runner ^1.0.0
json_serializable ^1.5.1
test ^1.3.4