Giter Site home page Giter Site logo

robiness / teledart Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dinoleung/teledart

0.0 0.0 0.0 910 KB

A Dart library interfacing with the latest Telegram Bot API.

Home Page: https://pub.dev/packages/teledart

License: GNU General Public License v3.0

Shell 0.03% Dart 99.97%

teledart's Introduction

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',
          input_message_content: InputTextMessageContent(
              message_text: '*pong*', parse_mode: 'MarkdownV2')),
      InlineQueryResultArticle(
          id: 'ding',
          title: 'ding',
          input_message_content: InputTextMessageContent(
              message_text: '*_dong_*', parse_mode: 'MarkdownV2')),
    ]));

Bugs and feature requests

Please file feature requests and bugs at the issue tracker.

teledart's People

Contributors

dinoleung avatar robiness avatar flexagoon avatar moepoi avatar fushinori avatar simolus3 avatar glofru avatar syfulin avatar f3ath avatar gladimdim avatar konstantinullrich avatar tvolkert avatar brhanem avatar marchellodev avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.