teledart 0.0.19

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

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.19 #

  • Update readme
  • Update description

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

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub 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.31 May 26, 2019 Go to the documentation of teledart 0.0.31 Download teledart 0.0.31 archive
0.0.30 Apr 27, 2019 Go to the documentation of teledart 0.0.30 Download teledart 0.0.30 archive
0.0.29 Apr 27, 2019 Go to the documentation of teledart 0.0.29 Download teledart 0.0.29 archive
0.0.28 Apr 7, 2019 Go to the documentation of teledart 0.0.28 Download teledart 0.0.28 archive
0.0.27 Feb 21, 2019 Go to the documentation of teledart 0.0.27 Download teledart 0.0.27 archive
0.0.26 Feb 20, 2019 Go to the documentation of teledart 0.0.26 Download teledart 0.0.26 archive
0.0.25 Feb 17, 2019 Go to the documentation of teledart 0.0.25 Download teledart 0.0.25 archive
0.0.24 Feb 5, 2019 Go to the documentation of teledart 0.0.24 Download teledart 0.0.24 archive
0.0.23 Feb 5, 2019 Go to the documentation of teledart 0.0.23 Download teledart 0.0.23 archive
0.0.22 Dec 2, 2018 Go to the documentation of teledart 0.0.22 Download teledart 0.0.22 archive

All 30 versions...

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

We analyzed this package on May 30, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.3.1
  • pana: 0.12.17

Platforms

Detected platforms: Flutter, other

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

Health suggestions

Fix lib/src/telegram/telegram.dart. (-15.25 points)

Analysis of lib/src/telegram/telegram.dart reported 33 hints, including:

line 195 col 11: DO use curly braces for all flow control structures.

line 197 col 11: DO use curly braces for all flow control structures.

line 217 col 11: DO use curly braces for all flow control structures.

line 258 col 11: DO use curly braces for all flow control structures.

line 260 col 11: DO use curly braces for all flow control structures.

Fix lib/src/teledart/teledart.dart. (-10.44 points)

Analysis of lib/src/teledart/teledart.dart reported 22 hints, including:

line 57 col 43: Use = to separate a named parameter from its default value.

line 59 col 5: Future results in async function bodies must be awaited or marked unawaited using package:pedantic.

line 62 col 11: DO use curly braces for all flow control structures.

line 80 col 18: Use = to separate a named parameter from its default value.

line 81 col 16: Use = to separate a named parameter from its default value.

Fix lib/src/teledart/fetch/webhook.dart. (-4.41 points)

Analysis of lib/src/teledart/fetch/webhook.dart reported 9 hints, including:

line 44 col 17: Use = to separate a named parameter from its default value.

line 47 col 27: Use = to separate a named parameter from its default value.

line 49 col 9: Use contains instead of indexOf

line 50 col 7: DO use curly braces for all flow control structures.

line 53 col 7: DO use curly braces for all flow control structures.

Fix additional 4 files with analysis or formatting issues. (-12.33 points)

Additional issues in the following files:

  • lib/src/teledart/fetch/long_polling.dart (8 hints)
  • lib/src/telegram/http_client.dart (6 hints)
  • lib/src/telegram/model.dart (6 hints)
  • lib/src/teledart/event/event.dart (5 hints)

Maintenance suggestions

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

While nothing is inherently wrong with versions of 0.0.*, it might mean 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+2
json_annotation ^1.2.0 1.2.0 2.4.0
Transitive dependencies
async 2.2.0
charcode 1.1.2
collection 1.14.11
http_parser 3.1.3
meta 1.1.7
path 1.6.2
pedantic 1.7.0
source_span 1.5.5
string_scanner 1.0.4
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
build_runner ^1.0.0
json_serializable ^1.5.1
test ^1.3.4