dart_telegram_bot 0.4.0-beta.2 copy "dart_telegram_bot: ^0.4.0-beta.2" to clipboard
dart_telegram_bot: ^0.4.0-beta.2 copied to clipboard

outdated

A basic Telegram Bot API wrapper made to make fast Telegram bots with as less code as possible.

example/main.dart

import 'dart:io';

import 'package:dart_telegram_bot/dart_telegram_bot.dart';
import 'package:dart_telegram_bot/telegram_entities.dart';

class SimpleBot extends Bot {
  SimpleBot() : super(Platform.environment['BOT_TOKEN']!);
}

void main() {
  SimpleBot().init().then((bot) async {
    late ChatID stopFrom;
    bot.onUpdate((u) async {
      if (u.message!.text == 'stop') {
        stopFrom = ChatID(u.message!.chat.id);
        await bot.sendMessage(ChatID(u.message!.chat.id), 'Stopping...');
        bot.stop(true);
      }
    });
    await bot.start(true).then((bot) async {
      await bot.sendMessage(stopFrom, 'Stopped');
      exit(0);
    });
  }).catchError((e, s) {
    print('$e\n$s');
    exit(1);
  });
}
48
likes
0
points
153
downloads

Publisher

unverified uploader

Weekly Downloads

A basic Telegram Bot API wrapper made to make fast Telegram bots with as less code as possible.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

http, logging

More

Packages that depend on dart_telegram_bot