telegrambot 0.1.0

  • Example
  • Installing
  • Versions
  • 46

Telegram Bot


Library to implement a Telegram Bot.


var bot = new TelegramBot('<token>');

var updates = pollForUpdates(bot);

await for (var update in updates) {
  if (update.message != null) {
      bot.sendCommand(new SendMessage.plainText(,
          "Hello, I'm just a bot. Don't expect too much from me."));


  • Poll for incoming messages
  • Sending text messages
    • Plaintext, html, markdown
    • Reply, Forward
    • Keyboards
  • Inline bot
    • Reply with text
    • Reply with GIF
    • Support for InlineKeyboard

Missing Features

  • Webhooks
  • Audio/Video/Files/Photos
  • Chat Management
  • Games
  • Payments
  • Framework
    • Logging
    • Error handling
    • Strong validation

License and contributors



  • Initial version.


// Copyright (c) 2017, TOPdesk. Please see the AUTHORS file for details.
// All rights reserved. Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

import 'dart:async';
import 'dart:io';
import 'package:telegrambot/telegrambot.dart';

Future<dynamic> main(List<String> args) async {
  if (args.length != 1) {
    print('Usage: example <token>');
  var token = args[0];
  var bot = new TelegramBot(token);

  var updates = pollForUpdates(bot);

  await for (var update in updates) {
    if (update.inlineQuery != null) {
      handleInlineQuery(bot, update.inlineQuery);
    if (update.message != null) {
      handleMessage(bot, update.message);

void handleMessage(TelegramBot bot, Message message) {
  bot.sendCommand(new SendMessage.plainText(,
      "Hello, I'm just a bot. Don't expect too much from me."));

const _pageSize = 10;

void handleInlineQuery(TelegramBot bot, InlineQuery inlineQuery) {
  var offset =
      (inlineQuery.offset ?? '').isEmpty ? 0 : int.parse(inlineQuery.offset);

  var results = <InlineQueryResult>[];
  var i = offset;
  for (; i < inlineQuery.query.runes.length && i - offset < _pageSize; i++) {
      new InlineQueryResultArticle(
          'At least ${i+1}',
          new InputTextMessageContent.markdown(
              'The sent text contains _at least_ ${i+1} characters.')),
  var nextOffset = i < inlineQuery.query.length ? '$i' : null;
  bot.sendCommand(new AnswerInlineQuery(,
    nextOffset: nextOffset,
    switchPmText: 'Chat with me',
    switchPmParameter: 'chat',

Use this package as a library

1. Depend on it

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

  telegrambot: "^0.1.0"

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:telegrambot/telegrambot.dart';
Version Uploaded Documentation Archive
0.1.0 Sep 22, 2017 Go to the documentation of telegrambot 0.1.0 Download telegrambot 0.1.0 archive


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

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


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


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:telegrambot/telegrambot.dart.


  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 4 errors 12 hints.

    Strong-mode analysis of lib/src/impl/model.dart failed with the following error:

    line: 1017 col: 31
    The argument type '(Map<String, Object>) → _User' can't be assigned to the parameter type '(dynamic) → User'.

    Strong-mode analysis of lib/src/impl/annotation.dart gave the following hint:

    line: 26 col: 40
    Unnecessary cast.

    Similar analysis of the following files failed:

    • lib/src/impl/util.dart (hint)
  • 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.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.24.2 <2.0.0
http ^0.11.3+14 0.11.3+16
Transitive dependencies
async 2.0.7
charcode 1.1.1
collection 1.14.10
http_parser 3.1.2
path 1.6.0
source_span 1.4.0
string_scanner 1.0.2
typed_data 1.1.5
Dev dependencies
test ^0.12.0