teledart 0.0.32

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 = TeleDart(Telegram('YOUR_BOT_TOKEN'), Event());

  teledart.start().then((me) => print('${me.username} is initialised'));

  teledart
        .onCommand('hello')
        .listen(((message) => teledart.replyMessage(message, 'world')));
}

Modifying Stream:

teledart
      .onMessage(keyword: 'dart')
      .where((message) => message.text.contains('telegram'))
      .listen((message) => teledart.replyPhoto(
          message,
          //  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 example:

teledart
      .onInlineQuery()
      .listen((inlineQuery) => teledart.answerInlineQuery(inlineQuery, [
            InlineQueryResultArticle()
              ..id = 'ping'
              ..title = 'ping'
              ..input_message_content = (InputTextMessageContent()
                ..message_text = '*pong*'
                ..parse_mode = 'markdown'),
            InlineQueryResultArticle()
              ..id = 'ding'
              ..title = 'ding'
              ..input_message_content = (InputTextMessageContent()
                ..message_text = '_dong_'
                ..parse_mode = 'markdown')
          ]));

Bugs and feature requests #

Please file feature requests and bugs at the issue tracker.

0.032 #

  • Prepare for upcoming change to HttpRequest and HttpClientResponse

0.0.31 #

  • Fixed styling with if statments
  • Updated readme and example

0.0.30 #

Breaking change #

  • Changed startFetching() into start(), and it returns a User object which represents the bot.

0.0.29 #

  • Fixed up webhook workflow
  • Added example to setup webhook
  • Support API 4.2

0.0.28 #

  • Modulised model files
  • Updated examples

0.0.27 #

  • Fixed #48

0.0.26 #

  • Fixed #46

0.0.25 #

  • Downgrade http package to ^0.11.3, to be compatible with firebase

0.0.24 #

  • Added pedantic package to dev dependencies

0.0.23 #

  • Fixes #40
  • Fixes #41
  • Follow new styling guide

0.0.22 #

  • Better dartdoc

0.0.21 #

  • Hot fix #36, toJSON() passing null values explicitly

0.0.20 #

  • Hot fix #34 400 Bad Request: field "keyboard" of the ReplyKeyboardMarkup should be an Array of Arrays
  • Fixed getUserProfilePhotos() returns UserProfilePhotos instead of List

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' show Platform;
// import 'dart:io' as io;

import 'package:teledart/teledart.dart';
import 'package:teledart/telegram.dart';
import 'package:teledart/model.dart';

void main() {
  final Map<String, String> envVars = Platform.environment;

  TeleDart teledart = TeleDart(Telegram(envVars['BOT_TOKEN']), Event());

  // TeleDart uses longpull by default.
  teledart.start().then((me) => print('${me.username} is initialised'));

  // In case you decided to use webhook.
  // teledart.setupWebhook(envVars['HOST_URL'], envVars['BOT_TOKEN'],
  //     io.File(envVars['CERT_PATH']), io.File(envVars['KEY_PATH']),
  //     port: int.parse(envVars['BOT_PORT']));
  // teledart
  //     .start(webhook: true)
  //     .then((me) => print('${me.username} is initialised'));

  // You can listen to messages like this
  teledart.onMessage(entityType: 'bot_command', keyword: 'start').listen(
      (message) =>
          teledart.telegram.sendMessage(message.chat.id, 'Hello TeleDart!'));

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

  // You can even filter streams with stream processing methods
  // See: https://www.dartlang.org/tutorials/language/streams#methods-that-modify-a-stream
  teledart
      .onMessage(keyword: 'dart')
      .where((message) => message.text.contains('telegram'))
      .listen((message) => teledart.replyPhoto(
          message,
          //  io.File('example/dash_paper_plane.png'),
          'https://raw.githubusercontent.com/DinoLeung/TeleDart/master/example/dash_paper_plane.png',
          caption: 'This is how Dash found the paper plane'));

  // Inline mode.
  teledart
      .onInlineQuery()
      .listen((inlineQuery) => teledart.answerInlineQuery(inlineQuery, [
            InlineQueryResultArticle()
              ..id = 'ping'
              ..title = 'ping'
              ..input_message_content = (InputTextMessageContent()
                ..message_text = '*pong*'
                ..parse_mode = 'markdown'),
            InlineQueryResultArticle()
              ..id = 'ding'
              ..title = 'ding'
              ..input_message_content = (InputTextMessageContent()
                ..message_text = '_dong_'
                ..parse_mode = 'markdown')
          ]));
}

Use this package as a library

1. Depend on it

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


dependencies:
  teledart: ^0.0.32

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';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
68
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
82
Learn more about scoring.

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

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: Flutter, other

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

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+2 0.12.0+2
json_annotation ^2.4.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
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.4.0
json_serializable ^3.0.0
pedantic ^1.7.0 1.8.0+1
test ^1.6.3

Admin