पैकेज, रिपॉज़िटरी और ऐप श्रेणियाँ खोजें

GitHub रिपॉज़िटरीKaikyuLotus/dart-telegram-bot

dart-telegram-bot

टेलीग्राम बॉट एपीआई के लिए एक सरल शुद्ध व्रैपर

dart-telegram-bot प्रोजेक्ट कवर
स्टार
29
फ़ोर्क
8
अंतिम पुश (UTC)
2 जन॰ 2025
प्रोजेक्ट स्थिति
सक्रिय

मूल README

यह अंग्रेज़ी मूल स्नैपशॉट है। नवीनतम सामग्री GitHub पर देखें।

Dart Telegram Bot Dart CI/CD

Dart Telegram Bot is a Dart wrapper for Telegram bot API.
It is compatible with Native, Flutter and JS.

Bot API Version Dart Version

Using Dart Telegram Bot is straightforward, here's an example echo bot:

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

void main() {
  Bot(
    // Insert your bot token here
    token: 'BOT_TOKEN',
    // Once the bot is ready this function will be called
    // You can start the bot here
    onReady: (bot) => bot.start(clean: true),
    // Register a new callback for new updates
  ).onUpdate((bot, update) async {
    // Send a message to the update chat with the received message
    bot.sendMessage(ChatID(update.message!.chat.id), update.message!.text!);
  });
}

Bot start may fail when bot token is invalid or with network issues.
To handle such cases follow the next example:

void main() {
  Bot(
    token: 'BOT_TOKEN',
    onReady: (bot) => bot.start(clean: true),
    // Handle start failure
    onStartFailed: (bot, e, s) => print('Start failed'),
  );
}

Also, you may want to disable or allow only certain update types.
To do so follow the next example:

void main() {
  Bot(
    token: 'BOT_TOKEN',
    onReady: (bot) => bot.start(clean: true),
    // Either allow all types but some
    allowedUpdates: UpdateType.allBut([UpdateType.channelPost]),
    // OR allow only a list of types
    allowedUpdates: [UpdateType.message, UpdateType.editedMessage],
  );
}

Dart Telegram Bot also supports a more OOP approach. The following example is still an echo bot, this time with OOP approach:

class MyBot extends Bot {

  MyBot() : super(token: 'BOT_TOKEN') {
    onUpdate(updateHandler);
  }

  @override
  Future onReady(Bot bot) => bot.start(clean: true);

  @override
  Future onStartFailed(Bot bot, Object err, StackTrace st) async {
    print('Bot failed to start: $err');
  }

  Future updateHandler(Bot bot, Update update) async {
    bot.sendMessage(ChatID(update.message!.chat.id), update.message!.text!);
  }
}

Written by Kaikyu Lotus (Telegram)

Kaikyu GitHub avatar
GitHub लेखक

Kaikyu ↗

Weeb developer

Italy
भाषाएँDart

श्रेणियाँ

उपयोग की गई निर्भरताएँ

निर्भरता सूची 4 आइटम

अपने प्रोजेक्ट के लिए रिपॉज़िटरी कैसे चुनें?

उपयोग के अनुसार छाँटें, गतिविधि की तुलना करें और अपनाने से पहले मूल प्रोजेक्ट की आवश्यकताएँ जाँचें।

  1. नाम, लेखक या विवरण से खोजें और तकनीकी विषय से परिणाम सीमित करें।
  2. स्टार, फ़ोर्क और हाल के पुश की तुलना करें। स्टार रुचि दर्शाते हैं, गुणवत्ता की गारंटी नहीं।
  3. उपयोग से पहले GitHub पर README, लाइसेंस और Issues जाँचें।

स्रोत और रखरखाव

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗