teledart 0.0.8

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

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

Bugs and feature requests

Please file feature requests and bugs at the issue tracker.

0.0.1

  • Initial version, created by Stagehand

0.0.2

  • First release

0.0.3

  • Edited README.md

0.0.4

  • More editing on README.md

0.0.5

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

0.0.6

  • Edit README.md

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

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.8"

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.8 Jun 19, 2018 Go to the documentation of teledart 0.0.8 Download teledart 0.0.8 archive
0.0.7 Jun 10, 2018 Go to the documentation of teledart 0.0.7 Download teledart 0.0.7 archive
0.0.6 May 28, 2018 Go to the documentation of teledart 0.0.6 Download teledart 0.0.6 archive
0.0.5 May 28, 2018 Go to the documentation of teledart 0.0.5 Download teledart 0.0.5 archive
0.0.4 May 27, 2018 Go to the documentation of teledart 0.0.4 Download teledart 0.0.4 archive
0.0.3 May 27, 2018 Go to the documentation of teledart 0.0.3 Download teledart 0.0.3 archive
0.0.2 May 27, 2018 Go to the documentation of teledart 0.0.2 Download teledart 0.0.2 archive

Analysis

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

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3

Scores

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

Platforms

Detected platforms: Flutter, other

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

Suggestions

  • The description is too short.

    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-v1 release.

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

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.24.3 <2.0.0
dartson >=0.2.0 <0.3.0 0.2.7
http ^0.11.3+16 0.11.3+16
Transitive dependencies
analyzer 0.29.11 0.32.1
args 0.13.7 1.4.3
async 2.0.7
barback 0.15.2+16
charcode 1.1.1
cli_util 0.0.1+2 0.1.3
collection 1.14.10
convert 2.0.1
crypto 2.0.5
csslib 0.14.4
glob 1.1.5
html 0.13.3+1
http_parser 3.1.2
isolate 1.1.0 2.0.1
logging 0.11.3+1
meta 1.1.5
package_config 1.0.3
path 1.6.1
plugin 0.2.0+2
pool 1.3.5
source_maps 0.10.5
source_span 1.4.0
stack_trace 1.9.2
string_scanner 1.0.2
typed_data 1.1.5
utf 0.9.0+4
watcher 0.9.7+8
when 0.2.0
which 0.1.3
yaml 2.1.14
Dev dependencies
test ^0.12.0