GithubHelp home page GithubHelp logo

dinoleung / teledart Goto Github PK

View Code? Open in Web Editor NEW
307.0 16.0 68.0 1.23 MB

A Dart library interfacing with the latest Telegram Bot API.

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

License: GNU General Public License v3.0

Dart 99.97% Shell 0.03%
telegram-bot-api telegram dart telegram-bot telegram-bot-sdk

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',
          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.

teledart's People

Contributors

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

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

teledart's Issues

Flutter app usage advice

Is there anything preventing this being used as a communications system from inside a Flutter app.
Sorry i am so lazy about checking the transport but ...

I assume that https://github.com/DinoLeung/DartWiseBot could just also be wrapped with a Dart GRPC, and then the Flutter GRPC uses it.

But i was hoping to be able to go direct from Flutter to Telegram without a Server in the middle.

The other way is to embed golang inside the FLutter app using https://github.com/go-telegram-bot-api/telegram-bot-api
thats just a gomobile compile away and some tinkering.

Exceptions for actual errors (no json response)

Describe the bug

I managed to generate a "Bad Request" error (by sending parse_mode: 'MarkdownV2' on sendMessage), which just gives me an exception as "HttpClientException: null null" - I ended up having to put a breakpoint in your http client code to figure out what it was trying to tell me.

To Reproduce

Snippet to reproduce the behavior:

teledart.telegram.sendMessage($someuserid, 'Some long text', parse_mode: 'MarkdownV2');

Expected behavior

The client should output HttpClientException: (400) (Bad Request)

Additional context

As to why I'm getting a Bad Request, I'm not sure - I've messaged telegram support to ask why (as teledart is just passing through my parse_mode string)

send media function

Function to send all types of media from File Id
send_media function short a lot if things
send photos, videos, audios, sticker .. etc from telegram file id

answerInlineQuery crashes

Describe the bug

Unhandled exception:
type 'Future' is not a subtype of type 'FutureOr'

To Reproduce

Snippet to reproduce the behaviour:

teledart.answerInlineQuery(inlineQuery, results);

HttpClient exception typo bug

The exception is thrown after the bot tries to reply to the user (replyMessage (...)), after the user first wrote a message to the chatbot (which was not launched yet), and then "Delete and stop" the chatbot:

Unhandled Exception:
HttpClientException: null null.

or in other words:

  1. The chatbot is not running.
  2. The user sends a message to the chatbot.
  3. User "Delete and stop" chatbot.
  4. Chatbot starts ...
  5. An exception is thrown:

Unhandled exception:
HttpClientException: null null

Update to Bot Api 4.3

Bot api updated to 4.3

  • Added support for Seamless Telegram Login on external websites
  • Added the new object LoginUrl and the new field login_url to the InlineKeyboardButton object which allows to automatically authorize users before they go to a URL specified by the bot. Users will be asked to confirm authorization in their Telegram app (needs version 5.7 or higher) when they press the button.
  • Added the field reply_markup to the Message object, containing the inline keyboard attached to the message
  • If a message with an inline keyboard is forwarded, the forwarded message will now have an inline keyboard if the keyboard contained only url and login_url buttons or if the message was sent via a bot and the keyboard contained only url, login_url, switch_inline_query or switch_inline_query_current_chat buttons. In the latter case, switch_inline_query_current_chat buttons are replaced with switch_inline_query buttons.
  • Bots now receive the edited_message Update even if only Message.reply_markup has changed.
  • Bots that have the can_edit_messages right in a channel can now use the method editMessageReplyMarkup for messages written by other administrators forever without the 48 hours limit.
  • Don't forget that starting in July 2019, webhook requests from Bot API will be coming from the subnets 149.154.160.0/20 and 91.108.4.0/22. Most users won't need to do anything to continue receiving webhooks. If you control inbound access with a firewall, you may need to update your configuration. You can always find the list of actual IP addresses of servers used to send webhooks there: https://core.telegram.org/bots/webhooks.

Every Thing From Here

Wrong detection of entityType in onMessage()?

I tried running TeleDart_example.dart and when I send any message that was not a registered command (ie. /start), example crashed with this error:

Unhandled exception:
NoSuchMethodError: The method 'substring' was called on null.
Receiver: null
Tried calling: substring(1)
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
#1      Event.onMessage.<anonymous closure> (package:teledart/src/teledart/event/event.dart:95:22)
#2      _WhereStream._handleData (dart:async/stream_pipe.dart:203:19)
#3      _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:166:13)
#4      _RootZone.runUnaryGuarded (dart:async/zone.dart:1316:10)
#5      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:338:11)
#6      _DelayedData.perform (dart:async/stream_impl.dart:593:14)
#7      _StreamImplEvents.handleNext (dart:async/stream_impl.dart:709:11)
#8      _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:669:7)
#9      _microtaskLoop (dart:async/schedule_microtask.dart:43:21)
#10     _startMicrotaskLoop (dart:async/schedule_microtask.dart:52:5)
#11     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:393:30)
#12     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:418:5)
#13     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)

I've attached screenshot from Telegram app for clarity:
teledart

I don't see any error in TeleDart_example.dart so I assume that the error is not on my side.

pubspec.yaml:

...
environment:
  sdk: '>=2.4.0 <3.0.0'

dependencies:
  teledart: ^0.0.37
...

dart --version:
Dart VM version: 2.7.2 (Mon Mar 23 22:11:27 2020 +0100) on "windows_x64"

About node.js support

Hello Dino!

I just forked your repository and was trying to make a compatilble version of the library with the javascript generated by https://pub.dev/packages/build_node_compilers

It is actually easy to make a node compatible project. I just added some conditional imports to teledart to import either the standard dart:io and http or the node_io or node_http depending on the build environment.

This is the current import for your http_client class:

image

But there is a huge issue. Not all methods and classes from http are implemented on node_http, and one of the is the MultipartRequest . Also, the SecurityContext the you use on the class WebHook also is not implemented yet.

This are some erros we get when trying to compile it to node:

Error: 'MultipartFile' isn't a type.
  Future<dynamic> httpMultipartPost(String url, List<http.MultipartFile> files,
                                                          ^^^^^^^^^^^^^
Error: Method not found: 'MultipartRequest'.
    var request = http.MultipartRequest('POST', Uri.parse(url))
                  ^^^^^^^^^^^^^^^^
Error: Method not found: 'HttpServer.bindSecure'.
    Future<dynamic> serverFuture = io.HttpServer.bindSecure(
                                                 ^^^^^^^^^^
-------------------------------------------------------------------------------
Error: Method not found: 'SecurityContext'.
    _context = io.SecurityContext();
               ^^^^^^^^^^^^^^^
Error: Getter not found: 'anyIPv4'.
        io.InternetAddress.anyIPv4.address, port, _context);
                           ^^^^^^^

My question is: are those classes really needed for the working of the library? There is a way to replace them by other types?

What do you think?

fromJson methods documentation / examples

Is your feature request related to a problem?

Kinda - I don't understand how to use the fromJson methods, eg the one for ReplyKeyboardMarkup, I assumed it would take a json string, instead it takes a Map<String, dynamic>, what keys are expected in that?

Describe the solution you'd like

Add some doc examples of how the fromJson methods can be called

Additional context

default case in event.onMessage() need to be generic

Is your feature request related to a problem?

Currently the library cannot listen to message type which is not support at the moment. So when telegram roll out new attributes developers need to wait until the library get updated.

Describe the solution you'd like

Make the default case in event.onMessage() returns message with entityType keyword input.

expect to looks like:

event.onMessage(entityType: 'unsupported_type', keyword: 'keyword').listen((msg) => {})

removeLongPolling does not stop long polling

Describe the bug

The call to removeLongPolling does not stop the longpolling recursive loop to make GET requests to Telegram API URL.

To Reproduce

call

teledart.removeLongPolling();

Expected behavior

The bot stops responding to Telegram messages. The recursive loop is stopped.

Actual behavior

The polling continues and GET requests are sent to Telegram API. Bot continues to answer user messages.

Finding a keyword in a message with

Is it possible to use teledart to process a message with a keyword if the message contains a hashtag?

 teledart
  ..start(webhook: false).then((User user) => me = user)

  // Will not work if the message has a hashtag:
  ..onMessage(keyword: 'Hi').listen((message) {teledart.replyMessage(message, 'Hello');})
  
  ..onHashtag().listen((message) {teledart.replyMessage(message, 'I\'ts hashtag');});

Example: https://ibb.co/JC7HTrs,

Can't send Polls

Describe the bug

When trying to send a poll a get :

Unhandled exception:
HttpClientException: HttpClientException: 400 Bad Request: can't parse options JSON object
#0      Telegram.sendPoll (package:teledart/src/telegram/telegram.dart:830:29)

To Reproduce

Snippet to reproduce the behavior:

sendPoll(22, "My Question", List<String>()..addAll(['Choice1', 'Choice2']));

To solve

Replace in method Telegram.sendPoll (line 824)
https://github.com/DinoLeung/TeleDart/blob/master/lib/src/telegram/telegram.dart#L825

'options': options,

by

'options': jsonEncode(options),

What about getting updates like new member?

In NodeJS (actually in Telegraf) you write
bot.on('new_chat_members', (ctx) => console.log(ctx))
and it will handle new chat member, but here I can't find anything like this.
What about this feature?

restrictChatMember cant convert chat permissions object to an encodable object

Describe the bug

I am trying to mute users, but instead i get this error:
Converting object to an encodable object failed: Instance of 'ChatPermissions'

To Reproduce

Snippet to reproduce the behavior:

var chat_id = message.chat.id;
var user_id = message.user.id;
var permissions = new ChatPermissions(can_send_messages: false);
var until_date = DateTime.now().millisecondsSinceEpoch + (7 * 24 * 60 * 60);
telegram.restrictChatMember(chat_id, user_id,
               permissions: permissions, until_date: until_date);

Expected behavior

I expected that the user is muted, but it was not muted.

Additional context

The user has no admin rights, it's a supergroup and i'm a dart newbie.

Keyword detection in message with hashtag

Is it possible to use teledart to process a message with a keyword if the message contains a hashtag?

 teledart
  ..start(webhook: false).then((User user) => me = user)

  // Will not work if the message has a hashtag:
  ..onMessage(keyword: 'Hi').listen((message) {teledart.replyMessage(message, 'Hello');})
  
  ..onHashtag().listen((message) {teledart.replyMessage(message, 'I\'ts hashtag');});

Example: https://ibb.co/JC7HTrs,

Unhandled LongPollingException

Describe the bug

Unhandled exception after a few hours LongPollingException: HttpClientException: SocketException: Failed host lookup: 'api.telegram.org' (OS Error: nodename nor servname provided, or not known, errno = 8)

Logs

Unhandled exception:
LongPollingException: HttpClientException: SocketException: Failed host lookup: 'api.telegram.org' (OS Error: nodename nor servname provided, or not known, errno = 8)
#0      LongPolling._recursivePolling.<anonymous closure> (package:teledart/src/teledart/fetch/long_polling.dart:97:21)
#1      _rootRunUnary (dart:async/zone.dart:1132:38)
#2      _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#3      _FutureListener.handleError (dart:async/future_impl.dart:144:20)
#4      Future._propagateToListeners.handleError (dart:async/future_impl.dart:651:47)
#5      Future._propagateToListeners (dart:async/future_impl.dart:672:24)
#6      Future._completeError (dart:async/future_impl.dart:491:5)
#7      _SyncCompleter._completeError (dart:async/future_impl.dart:55:12)
#8      _Completer.completeError (dart:async/future_impl.dart:27:5)
#9      _AsyncAwaitCompleter.completeError (dart:async-patch/async_patch.dart:40:18)
#10     Telegram.getUpdates (package:teledart/src/telegram/telegram.dart)

Type of parameters in methods

I have wrote this code:

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

void main(List<String> args) {
  TeleDart t = TeleDart(Telegram('token'), Event());
  t.startFetching();

  final btns = <List<KeyboardButton>>[<KeyboardButton>[KeyboardButton(text: 'Yes'), KeyboardButton(text: 'No')]];

  final keyboard = ReplyKeyboardMarkup(keyboard: btns);

  t.onCommand('start').listen((msg) => t.replyMessage(msg, 'Some question?', reply_markup: keyboard));
}

And then a have got an error:

Unhandled exception:
HttpClientException:
HttpClientException:
400 Bad Request: can't parse keyboard button: Field "request_contact" must be of type Boolean
#0 Telegram.sendMessage (package:teledart/src/telegram/telegram.dart:109:29)
#1 TeleDart.replyMessage (package:teledart/src/teledart/teledart.dart:235:16)
#2 main. (file:///Users/ky/Projects/medical_bot/bin//bot.dart:13:42)

When I trying fix this (set true or false to parameter) - a new similar error is coming with other parameter. But they are optional and if I don't give them boolean value, they shouldn't influence my request.

Handling regular user's message.

Method onMessage(...) - handles all messages (commands, regular messages and so on).
When I try write /start in chat:

await _t.startFetching();
_t.onCommand('start').listen((msg) => _t.replyMessage(msg, 'text'));
_t.onMessage().listen((msg) => _t.replyMessage(msg, 'next text'));

All this methods are catch the same msg object and both of them print their message. I think it is unacceptable behavior. onMessage(...) don't need be able catch everything, why then more precise methods are created? Maybe I wrote a bad code?

Handling updates independently

Is your feature request related to a problem?

Yes. I want to have a Telegram bot written in Dart and deployed with Firebase Cloud Functions and webhooks so my cloud function gets called by Telegram app when users send messages to the bot. That's why I have to handle updates independently (I don't need to listen, i.e. to call start()). But the problem is that _updatesHandler() method is private.

So what I'm trying to achieve is this:
Set webhook manually with help of Telegram's setWebhook() method via http request to my cloud function, then

Telegram bot message -> Cloud function -> handle update

For example, in Node.JS framework called Telegraf, they have handleUpdate() method, and if I was using it, I would have to do something like this (to call handleUpdate() when my cloud function is called).

Describe the solution you'd like

I'd like to have the _updatesHandler() method public:

  /// Private method to add updates into events queue
  void updatesHandler(Update update) => _event.emitUpdate(update);

Or something similar:

  /// Handle raw Telegram update. In case you use centralized webhook server, queue, etc.
  void handleUpdate(Update update) => _updatesHandler(update);

Or any other solution...

Thanks!

There is no way to disable case sensitivity in the onMessage method

Hello!
Thank you for your work! We need to do something similar to the NLP algorithm. But, we cannot change the case sensitivity with the help of additional parameters. And we cannot change the case sensitivity in the RegExp object with the necessary parameters.
So you have to write something like this:
teledart.onMessage (keyword: r '(Hi|hi|hI|HI)')

The example is not running

I put my Token Telegram to test this example...(I´m sure my Token is Ok, because it´s running under my Qt application and my site ).

The "start" method is not working.

I updated all my dependecies like this example.

This is the message error:

Unhandled exception:
TeleDartException: TeleDartException: HttpClientException: HttpClientException: 404 Not Found
#0      TeleDart.start.<anonymous closure> (package:teledart/src/teledart/teledart.dart:70:27)
#1      _RootZone.runUnary (dart:async/zone.dart:1379:54)
#2      _FutureListener.handleError (dart:async/future_impl.dart:144:20)
#3      Future._propagateToListeners.handleError (dart:async/future_impl.dart:651:47)
#4      Future._propagateToListeners (dart:async/future_impl.dart:672:24)
#5      Future._completeError (dart:async/future_impl.dart:491:5)
#6      _SyncCompleter._completeError (dart:async/future_impl.dart:55:12)
#7      _Completer.completeError (dart:async/future_impl.dart:27:5)
#8      _RootZone.runBinary (dart:async/zone.dart:1384:54)
#9      _FutureListener.handleError (dart:async/future_impl.dart:140:20)
#10     Future._propagateToListeners.handleError (dart:async/future_impl.dart:651:47)
#11     Future._propagateToListeners (dart:async/future_impl.dart:672:24)
#12     Future._completeError (dart:async/future_impl.dart:491:5)
#13     _SyncCompleter._completeError (dart:async/future_impl.dart:55:12)
#14     _Completer.completeError (dart:async/future_impl.dart:27:5)
#15     _AsyncAwaitCompleter.completeError (dart:async-patch/async_patch.dart:40:18)
#16     Telegram.getMe (package:teledart/src/telegram/telegram.dart)
<asynchronous suspension>
#17     TeleDart._initBotInfo (package:teledart/src/teledart/teledart.dart:39:49)
<asynchronous suspension>
#18     TeleDart.start (package:teledart/src/teledart/teledart.dart:53:13)
<asynchronous suspension>
#19     main (file:///mnt/midia4/prj/Android/Telegram/bin/main.dart:14:12)
#20     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:300:19)
#21     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:171:12)

Am I doing anything wrong?
Greetings

edit on .onCommand

Make .onCommand accept list of commands
like .onCommand(["start", "help"]) and when user send /start or /help will get same message

Also prefix with on commands to select what command use
Like .onCommand("start", prefix: ["!", "/", "#"])
That is mean if message /start or /start or #start will deal with it as command and reply

Using Filters

So far we’ve seen how to register a callback function that executes every time a specific update comes from the server, but there’s much more than that to come.

Here we’ll discuss about Filters. Filters enable a fine-grain control over what kind of updates are allowed or not to be passed in your callback functions, based on their inner details.

Like What Pyrogram Do Here

More details Here

Forward as copy

Telegram have method to forward message but when you forward it will show you "forward from x user or x channel"

Add parameter with forward function
as_copy (bool, optional) – Pass True to forward messages without the forward header (i.e.: send a copy of the message content).

That will send same message like a normal message not forwarded

Smart Plugins

Smart Plugins powerful plugin system that is meant to further simplify the organization of large projects and to provide a way for creating pluggable (modular) components that can be easily shared across different applications with minimal boilerplate code

like the main file is main.dart
And there is folder in same path plugins
in side it the project files like welcome_message.dart and help_message.dart

More Information Here

Change primitives to Dart correspondents

Hello! Such an amazing library! Thank you so much for your work.

I am using it on a side project but I realized that some properties are impossible to know it's meaning by just looking into the code. For example:

  • The Message class has a propery named date (and forward_date and edit_date), as an int value. But what doest it mean? Is it milliseconds since epoch or microseconds? And it is UTC date?
  • The class Audio has a int property named duration. Is it seconds, milliseconds or microseconds?

For those two problems above there are 2 simple solutions:

  1. Change dates to DateTime objects.
  2. Change duration property to Duration objects.

Both are dart native objects :)
Hope you consider that request.

Best regards!

removeWebhook () doesn't work without setupWebhook (...)

The removeWebhook() method will work correctly only if the setupWebhook(...) method was called before it in the current script.

But if I am not using webhook, but want to make sure it is disabled, I can execute teledart.telegram.deleteWebhook();

To use this method:
teledart.removeWebhook()
I suggest adding a couple of lines of code to the removeWebhook() method:

  void removeWebhook() {
    if (_webhook != null) {
      _webhook.deleteWebhook().then((_) {
        _webhook.stopWebhook();
        _webhook = null;
      });
    } else { // +
      telegram.deleteWebhook(); // +
    } // +
  }

Fields in telegram objects

  1. In class InlineQueryResultGif lacks field thumb_mime_type.
  2. In class InlineQueryResultMpeg4Gif lacks field thumb_mime_type.
  3. In class PassportElementErrorUnspecified instead of file_hash there should be element_hash
  4. In method restrictChatMember(...) incorrectly formed value of requestUrl and unnecessary fields

instrutions

Hi dino,

I am trying to contact you my e-mail, but the e-mail in flutter [email protected] does not exists.

I am trying to port my telegram bot (today in ruby) to dart using your lib.
What version of flutter must be use?
I am using stable and when I open your example in the vscode, the packages:
import 'package:teledart/teledart.dart';
import 'package:teledart/telegram.dart';
import 'package:teledart/model.dart';
show as Target URI not found.

Thank you,
Paulo

Using proxy

It would be great to support proxies for countries like Russia where telegram is blocked :)

filename of send document

It looks like a file name cannot be specified for the document being sent right now. The file size value will be automatically substituted for the name. It would be convenient to set the file name in the parameters of the sendDocument (...) method.

Make API more Dart-y

I like the distinction of telegram and teledart – one is a simple typed wrapper around web requests, the other one a full-fledged powerful API that uses the capabilities of object-oriented programming. Some aspects like the inline mode are really great, but I think other parts could be a bit better.
For example, most requests still need to be made through the teledart instance with the exception of replies. I'd love it if you could simply send a message to a chat if you got hold of the Chat. Something like chat.send('Some text.').
Also, most fields currently have the name from the API in snake_case instead of using an adapted camelCase version. The typing could also be a bit stronger. For example, we could create a ChatId class to represent a reference to a Chat. Then we could do stuff like this:

final id = someMessage.chat.id;
final chat = await id.resolve();

We could also introduce classes for several other concepts to make them type-safe. Take photos for example. Currently, the telegram.sendPhoto function accepts dynamic as a photo and developers are forced to go to the Telegram API documentation to find out what they can send, but we could also create a Photo class which gets subclassed by PhotoUrl, and PhotoFile. Users could then create photos using Photo.fromUrl(…) and Photo.fromFile(…) constructors, which makes the API easier to use and explore.

Let me know what you think about this. I'd be happy to help implementing these changes.

how to delete message?

Can you give me a example how to delete a message?

There are no method when I try use teledart.deleteMessage(chat_id, message_id);

Thank you

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.