teledart 0.0.19

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

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 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.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
0.0.21 Nov 20, 2018 Go to the documentation of teledart 0.0.21 Download teledart 0.0.21 archive
0.0.20 Nov 18, 2018 Go to the documentation of teledart 0.0.20 Download teledart 0.0.20 archive
0.0.19 Oct 29, 2018 Go to the documentation of teledart 0.0.19 Download teledart 0.0.19 archive

All 27 versions...

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

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

  • Dart: 2.2.0
  • pana: 0.12.14

Platforms

Detected platforms: Flutter, other

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

Health suggestions

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

Analysis of lib/src/teledart/teledart.dart reported 20 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 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.

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

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

Analysis of lib/src/teledart/fetch/webhook.dart reported 5 hints:

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 77 col 5: Future results in async function bodies must be awaited or marked unawaited using package:pedantic.

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

Fix lib/src/teledart/fetch/long_polling.dart. (-1.99 points)

Analysis of lib/src/teledart/fetch/long_polling.dart reported 4 hints:

line 41 col 19: Use = to separate a named parameter from its default value.

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

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

line 75 col 13: Use isNotEmpty instead of length

Fix lib/src/teledart/event/event.dart. (-0.50 points)

Analysis of lib/src/teledart/event/event.dart reported 1 hint:

line 39 col 19: Use = to separate a named parameter from its default value.

Format lib/src/telegram/model.dart.

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

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.1.0
Transitive dependencies
async 2.1.0
charcode 1.1.2
collection 1.14.11
http_parser 3.1.3
meta 1.1.7
path 1.6.2
pedantic 1.5.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