FLUTTER ECOSYSTEM

DinoLeung/TeleDart

최신 Telegram Bot API와 인터페이스하는 Dart 라이브러리입니다.

TeleDart 프로젝트 이미지
Stars
309
Forks
71
최근 푸시(UTC)
2024. 4. 6.
프로젝트 상태
활성
Dino Leung GitHub avatar
GITHUB User

Dino Leung ↗

Just doing my own thing

Adelaide
언어DartShell

기술 주제

이 저장소가 배포한 패키지

사용 중인 의존성

의존성 목록 6 개

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

README 펼치기 / 접기

TeleDart

A clean implementation of Telegram bot API allows you to create your own easily.

TeleDart

Bot API Version Dart Version License: GPL v3

Readme Card

Creating a Telegram bot

In order to create a Telegram bot, you need to talk to @BotFather generating a bot token. Simply follow the instructions.

Usage

Initialising the bot:

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

void main() {
  var BOT_TOKEN = 'YOUR_BOT_TOKEN_FROM_BOT_FATHER';
  final username = (await Telegram(BOT_TOKEN).getMe()).username;
  var teledart = TeleDart(BOT_TOKEN, Event(username!));

  teledart.start()
}

A simple usage example:

teledart.onMessage(keyword: 'Fight for freedom')
    .listen((message) => message.reply('Stand with Hong Kong'));

Using bot commands:

// Long way
teledart.onMessage(entityType: 'bot_command', keyword: 'start')
    .listen((message) => teledart.sendMessage(message.chat.id, 'Hello TeleDart!'));

// Short way (recommended)
teledart.onCommand('glory')
    .listen((message) => message.reply('to Ukraine!'));

Modifying Stream:

teledart
    .onMessage(keyword: 'dart')
    .where((message) => message.text?.contains('telegram') ?? false)
    .listen((message) => message.replyPhoto(
        //  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) => inlineQuery.answer([
      InlineQueryResultArticle(
          id: 'ping',
          title: 'ping',
          inputMessageContent: InputTextMessageContent(
              messageText: '*pong*', parseMode: 'MarkdownV2')),
      InlineQueryResultArticle(
          id: 'ding',
          title: 'ding',
          inputMessageContent: InputTextMessageContent(
              messageText: '*_dong_*', parseMode: 'MarkdownV2')),
    ]));

Bugs and feature requests

Please file feature requests and bugs at the issue tracker.